Treat INACTIVE user status filter as all non-ACTIVE accounts.

Admin Inactive filter can return pending, deactivated, suspended, and any other non-active statuses in one query.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-08-04 16:53:13 +03:00
parent a3f4c1829d
commit 992cb3f5f1
3 changed files with 23 additions and 3 deletions

View File

@ -222,7 +222,17 @@ SELECT
FROM users
WHERE
(sqlc.narg('role')::TEXT IS NULL OR role = sqlc.narg('role')::TEXT)
AND (sqlc.narg('status')::TEXT IS NULL OR status = sqlc.narg('status')::TEXT)
AND (
sqlc.narg('status')::TEXT IS NULL
OR (
sqlc.narg('status')::TEXT = 'INACTIVE'
AND status <> 'ACTIVE'
)
OR (
sqlc.narg('status')::TEXT <> 'INACTIVE'
AND status = sqlc.narg('status')::TEXT
)
)
AND (sqlc.narg('query')::TEXT IS NULL OR (
first_name ILIKE '%' || sqlc.narg('query')::TEXT || '%'
OR last_name ILIKE '%' || sqlc.narg('query')::TEXT || '%'

View File

@ -524,7 +524,17 @@ SELECT
FROM users
WHERE
($1::TEXT IS NULL OR role = $1::TEXT)
AND ($2::TEXT IS NULL OR status = $2::TEXT)
AND (
$2::TEXT IS NULL
OR (
$2::TEXT = 'INACTIVE'
AND status <> 'ACTIVE'
)
OR (
$2::TEXT <> 'INACTIVE'
AND status = $2::TEXT
)
)
AND ($3::TEXT IS NULL OR (
first_name ILIKE '%' || $3::TEXT || '%'
OR last_name ILIKE '%' || $3::TEXT || '%'

View File

@ -436,7 +436,7 @@ func (h *Handler) CheckUserPending(c *fiber.Ctx) error {
// @Param page_size query int false "Page size"
// @Param created_before query string false "Created before (RFC3339)"
// @Param created_after query string false "Created after (RFC3339)"
// @Param status query string false "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED)"
// @Param status query string false "User account status filter (ACTIVE, PENDING, SUSPENDED, DEACTIVATED, or INACTIVE for all non-ACTIVE statuses)"
// @Param country query string false "Country filter (case-insensitive match on stored value)"
// @Param region query string false "Region filter (case-insensitive match on stored value)"
// @Param subscription_status query string false "Derived subscription filter: ACTIVE, PENDING, or Unsubscribed (matches response subscription_status semantics)"