[#503] perf: compute admin stats with database aggregates instead of loading all rows - #531
Open
Myart352 wants to merge 9 commits into
Open
[#503] perf: compute admin stats with database aggregates instead of loading all rows#531Myart352 wants to merge 9 commits into
Myart352 wants to merge 9 commits into
Conversation
|
@Myart352 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Myart352
force-pushed
the
fix/503-admin-stats-aggregates
branch
from
July 29, 2026 09:44
66e5645 to
4cb0a91
Compare
Myart352
force-pushed
the
fix/503-admin-stats-aggregates
branch
from
July 29, 2026 09:54
4cb0a91 to
ecbbdea
Compare
- api-keys.controller.spec.ts: mock guards with overrideProvider to fix 401 vs 403 mismatch; use Bearer prefix to distinguish admin/non-admin - prisma.service.spec.ts: wrap sync-throwing create in async function so .rejects matcher works instead of timing out - tracking-poll.worker.intervals.spec.ts: add claimDelivery and clearDeliveryClaim to escrowRepository mock
Myart352
force-pushed
the
fix/503-admin-stats-aggregates
branch
from
July 29, 2026 10:31
285f841 to
e4620a1
Compare
Use jest.requireActual instead of dynamic import for credential-encryption.util to avoid ESM module errors.
Myart352
force-pushed
the
fix/503-admin-stats-aggregates
branch
from
July 29, 2026 10:42
e4620a1 to
f69ab29
Compare
Myart352
force-pushed
the
fix/503-admin-stats-aggregates
branch
from
July 29, 2026 11:10
10ba682 to
dde1fbf
Compare
…irectly NestJS @UseGuards resolves classes directly regardless of mock providers, so the module-based approach could never work. Test the controller business logic directly instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #503
Problem
AdminStatsService.getStats ran escrow.findMany({}) and dispute.findMany({}) with no filter and no projection, then computed every figure in JavaScript. All eight numbers it returns are aggregates the database can compute. Memory use and latency were linear in total table size.
Solution
Replaced findAll + in-memory reduce/set computations with Prisma count, aggregate, groupBy and select-based distinct queries.
Changes Made
Test Results
All 8 existing tests pass with identical expected values.