Add daily-active-accounts computation job - #57
Merged
Conversation
New src/jobs/daily_active_accounts.rs, following the asset_revalidation.rs/ contract_event_listener.rs job pattern: counts distinct source_account rows in payments for the current UTC calendar day and upserts into network_daily_metrics (migration 031, included here since Stellar-Insightss#45 may not have landed yet). Registered in the scheduler and JOB_DAA_ENABLED/ JOB_DAA_INTERVAL_SECONDS documented in .env.example.
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 #2
Adds
src/jobs/daily_active_accounts.rs, following the existingasset_revalidation.rs/contract_event_listener.rsjob shape (configstruct with
enabled/interval_secondsfrom env,start()loop withJobMetricsCollector).the module doc comment since Add /api/v1/stats/summary endpoint: DAA, tx count 24h, payment volume 24h, active soroban contracts #1 and Add vs-yesterday delta calculation via previous-day snapshot storage #3 both need this to be unambiguous.
COUNT(DISTINCT source_account)from thepaymentstable fordate(created_at) = date('now'), per the issue's guidance to reusealready-extracted payment data rather than re-parsing ledgers.
so a crash mid-run means no write happens (never a partial/corrupt DAA
figure), matching the checkpoint-before-advance pattern used elsewhere.
network_daily_metrics(from Design and migrate time-series schema for daily network metrics #45's migration,included here as
migrations/031_...in case Design and migrate time-series schema for daily network metrics #45 hasn't merged yet).JobScheduler::start();JOB_DAA_ENABLED/JOB_DAA_INTERVAL_SECONDSdocumented in.env.example(default 900s).Note:
JobScheduler::start()itself doesn't appear to be called anywherein
main.rsyet (pre-existing, not introduced by this PR) — the job isregistered correctly and will run once the scheduler is wired up.