Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • A Ahad Mobile
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • holatech
  • Ahad Mobile
  • Merge requests
  • !131

fix(admin): list every card the dashboard counts on the Cards page

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Hung Hoang requested to merge hunghoang/fix/admin-cards-empty into develop Oct 18, 2026
  • Overview 0
  • Commits 2
  • Pipelines 2
  • Changes 21

Bug: https://hola-tech.sg.larksuite.com/record/Y3nJrSQUPeRQDUc5Up1lZdRlgtd

Problem. Dashboard "Total cards" showed 17 (16 Active, 1 Blocked) but /cards was empty. The Cards page, its summary strip and the user cards panel only read user_cards.provider = 'reap'; CardsService.createCard never set that column (nullable, no default), so every app-issued card was stored NULL. The dashboard count had no provider filter. While reproducing this, three more defects on the same screens showed up: /cards/:id always said "Could not load card details." (the admin schemas rejected NULL card name/last 4/provider and the decimal-string spend limit pg returns), and sorting /cards by Balance or a ledger by amount returned 500 (TypeORM skip/take with a join cannot order its id subquery by a raw CAST).

Fix.
- be: UserCardProvider enum; createCard stamps the provider; migration 1790500000003 backfills NULL and case variants to reap and sets the column default (1 s lock_timeout, restored afterwards). The dashboard tile counts the same provider = reap cards the page lists. Balance/amount sorts go through a selected alias with an id tie-break; a NULL balance sorts, filters and summarises as 0 (the summary average/lowest now include unfunded cards).
- admin: schemas accept the NULL fields and string spend limit; a shared cardLabel renders missing parts as a dash on the list, detail and user pages.

Deploy note. The old API keeps serving during migration:run and saves whole card entities, so a card loaded before the backfill could be written back NULL. After deploy, SELECT id FROM user_cards WHERE provider IS NULL should return nothing; the migration UPDATE is safe to re-run.

Tests.
- Offline SQL spec on real TypeORM metadata (runs in CI) + 7 Postgres parity tests (RUN_DB_TESTS=1 yarn jest admin-reap-cards.postgres --runInBand); both fail on develop for the reported reasons.
- BE card/admin/dashboard/reap suites pass, nest build OK, tsc error count unchanged (89 = develop). Admin 834/834 tests, tsc clean, lint 0 errors.
- Playwright on the local admin console over cards written through the app path: tile 17 = table 17 = summary 17, Blocked filter 1, balance sort, card detail and user cards panel all render.

Not tested: staging data; the live Reap master-account balance (no Reap key locally).

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: hunghoang/fix/admin-cards-empty