feat(realunit): add cron-cached admin KPI stats endpoint#3821
Open
TaprootFreak wants to merge 2 commits into
Open
feat(realunit): add cron-cached admin KPI stats endpoint#3821TaprootFreak wants to merge 2 commits into
TaprootFreak wants to merge 2 commits into
Conversation
Add GET /v1/realunit/admin/stats (REALUNIT/ADMIN role) returning aggregated RealUnit KPIs from an hourly cron-refreshed cache, mirroring the existing StatisticService pattern. - New RealUnitStatsService computes growth, KYC funnel, registration and trading KPIs over total/30d/7d windows via Promise.all - New RealUnitStatsDto contract with Period (total/last30Days/last7Days) - Add generic aggregate query helpers: KycAdminService.getKycStepCounts, UserDataService.getNewUserDataCount, UserService.getNewUserCount, TransactionService.getAssetTradingStats - Add Process.UPDATE_REALUNIT_STATS for cron disable support - Full unit coverage on new service, DTO and helper methods
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.
What
Adds a new cron-cached aggregate admin endpoint
GET /v1/realunit/admin/stats(roleREALUNIT/ADMIN) returning RealUnit KPIs. Mirrors the existingStatisticServicecron/cache pattern: an hourly@DfxCronrefreshes an in-memory cache; the route just returns it.Process.UPDATE_REALUNIT_STATSis added so the job can be disabled like other cron processes.A companion frontend PR lives in
DFXswiss/services; the DTO field names below are the shared contract.Response shape
Each KPI is reported over three windows: all-time
total,last30Days,last7Days. New reusable aggregate query helpers were added (all SQL-side, grouped counts/sums):KycAdminService.getKycStepCounts,UserDataService.getNewUserDataCount,UserService.getNewUserCount,TransactionService.getAssetTradingStats.Scoping / data-source notes
UserData(accounts) /User(wallets) bycreated. The API has no RealUnit-app client tag, so this is platform-wide growth, not RealUnit-only.KycSteps whose name is incontextRequiredSteps(REALUNIT_BUY)(canonical helper, not hardcoded).KycStephas no context column, so this is the step set used for RealUnit buy, not a per-user RealUnit filter; drop-off is derivable across steps.completed= steps withReviewStatus.COMPLETED.REALUNIT_REGISTRATIONKycStep —started(all),inReview(in-progress/review statuses),completed.SUM(amountInChf), rounded toConfig.defaultVolumeDecimal) and counts, split by buy/sell.Tests
100% coverage on new code (new service, new DTO, new helper methods). Cron is not auto-fired in tests;
doUpdate()is called directly thengetStats()asserted.format/lint/type-check/ fulljestsuite all green locally.