Skip to content

Add /api/v1/stats/summary endpoint - #59

Merged
christabel888 merged 1 commit into
Stellar-Insightss:mainfrom
ndii-dev:issue-1-stats-summary-endpoint
Aug 28, 2026
Merged

Add /api/v1/stats/summary endpoint#59
christabel888 merged 1 commit into
Stellar-Insightss:mainfrom
ndii-dev:issue-1-stats-summary-endpoint

Conversation

@ndii-dev

Copy link
Copy Markdown

Closes #1

Adds GET /api/v1/stats/summary to src/api/analytics_dashboard.rs,
structurally mirroring the existing /analytics/dashboard handler
(cached, utoipa-annotated, State<(Arc<Database>, Arc<CacheManager>, Arc<StellarRpcClient>, Arc<PriceFeedClient>)> — the same tuple state
already used by corridors/anchors cached 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).

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).
@christabel888
christabel888 merged commit fd84b8a into Stellar-Insightss:main Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /api/v1/stats/summary endpoint: DAA, tx count 24h, payment volume 24h, active soroban contracts

3 participants