Add /api/v1/stats/summary endpoint - #59
Merged
christabel888 merged 1 commit intoAug 28, 2026
Merged
Conversation
New handler in src/api/analytics_dashboard.rs mirroring its existing cached/utoipa-annotated style: DAA, 24h tx count, 24h USD payment volume (aggregated by asset and converted via the existing price feed, not pulled row-by-row), and active Soroban contract count, each with a vs-yesterday delta (folds in Stellar-Insightss#3). Cached via cached_query with the existing CACHE_DASHBOARD_STATS_TTL (folds in Stellar-Insightss#4) -- errors are never cached since cached_query only writes on success. Registered in v1's cached_routes and documented in src/openapi.rs under a new 'Overview' tag (folds in Stellar-Insightss#6).
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 #1
Adds
GET /api/v1/stats/summarytosrc/api/analytics_dashboard.rs,structurally mirroring the existing
/analytics/dashboardhandler(cached, utoipa-annotated,
State<(Arc<Database>, Arc<CacheManager>, Arc<StellarRpcClient>, Arc<PriceFeedClient>)>— the same tuple statealready used by
corridors/anchorscached routes).Fields: daily active accounts, 24h tx count, 24h payment volume (USD),
active Soroban contract count — each wrapped in a StatWithDelta carrying
a vs-yesterday percent change (folds in #3's delta logic; None rather
than a fabricated 0%/inf/NaN when there's no meaningful prior-day value).
Day boundary: UTC calendar day (date('now')), matching #2/#3's
convention, not a rolling 24h window — documented in the module comment.
Data source: computed directly from payments/contract_events rather than
depending on #2's job output, since this PR needs to stand alone and the
job may not have landed yet. Payment volume is aggregated by asset
(GROUP BY) and converted to USD via the existing price feed
(PriceFeedClient::get_prices, batch call) rather than summing raw
amounts across mismatched asset units. Cost scales with distinct assets,
not row count.
Caching (folds in #4): wrapped in cached_query with the existing
CACHE_DASHBOARD_STATS_TTL (default 60s) and a new keys::stats_summary()
cache key (no per-request dimension today). Errors are never cached —
cached_query only writes on success.
Docs (folds in #6): registered in src/openapi.rs under a new Overview
tag with StatWithDelta/StatsSummary schemas.
See #5 for the dedicated integration test (separate PR).