Skip to content

feat(data-processing): daily on-chain KPI snapshot scheduler#988

Open
olalois wants to merge 3 commits into
Pulsefy:mainfrom
olalois:feat/877-onchain-kpi-snapshot-scheduler
Open

feat(data-processing): daily on-chain KPI snapshot scheduler#988
olalois wants to merge 3 commits into
Pulsefy:mainfrom
olalois:feat/877-onchain-kpi-snapshot-scheduler

Conversation

@olalois

@olalois olalois commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Implements issue #877 — persists daily snapshots of core on-chain KPIs so trend analysis is cheap and consistent.

Changes

  • src/db/models.pyOnchainKpiSnapshot ORM model with columns: period_date (unique), tvl_xlm, volume_xlm, active_rounds, contribution_count, extra_data, captured_at
  • src/db/postgres_service.pysave_onchain_kpi_snapshot() (skips duplicate for same period_date) + get_onchain_kpi_snapshots()
  • alembic/versions/006_add_onchain_kpi_snapshots.py — migration with uq_onchain_kpi_snapshots_period_date unique constraint
  • src/snapshots/onchain_kpi_snapshot.py_fetch_kpis() collects TVL/volume from Stellar Horizon and active rounds/contribution counts from DB; run_onchain_kpi_snapshot_job() is the scheduler entry point with full error isolation
  • src/scheduler.py — job registered at 00:05 UTC daily via CronTrigger
  • tests/test_onchain_kpi_snapshot.py — 9 unit tests (all passing)

Acceptance Criteria

  • Captures TVL, volume, active rounds, and contribution counts
  • Runs on a daily schedule (00:05 UTC via CronTrigger)
  • Skips duplicate snapshots for the same period (unique constraint + service-level check)
  • Documented storage schema (model docstring + migration header)

Tested

9 passed in 0.03s

Closes #877

…#877)

- Add OnchainKpiSnapshot SQLAlchemy model (TVL, volume, active rounds,
  contribution count, extra_data, captured_at)
- Add save_onchain_kpi_snapshot (duplicate-skip) and
  get_onchain_kpi_snapshots to PostgresService
- Add Alembic migration 006 with unique constraint on period_date
- Add src/snapshots/onchain_kpi_snapshot.py: _fetch_kpis fetches from
  Stellar Horizon + DB; run_onchain_kpi_snapshot_job is the job entry point
- Register job daily at 00:05 UTC in AnalyticsScheduler
- Add 9 unit tests (all passing)

Closes Pulsefy#877
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@olalois 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! 🚀

Learn more about application limits

@Cedarich

Copy link
Copy Markdown
Contributor

@olalois Fix workflow

@Cedarich

Copy link
Copy Markdown
Contributor

@olalois please fix workflow

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.

Data-processing: Daily on-chain KPI snapshot scheduler

2 participants