feat: daily uptime points system with cron automation#497
Open
feat: daily uptime points system with cron automation#497
Conversation
The seed_featured_content migration (0037) assumed specific users always exist, causing crashes in test environments. Added try/except to skip seeding gracefully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…perations Major refactor of the add_daily_uptime management command: - Add --date, --start-date, --end-date params for backfilling historical data - Refactor from per-user DB saves to bulk_create with batch processing - Add snapshot-based activity verification with fallback for recent dates - Wrap all operations in atomic transaction for data consistency - Use shared leaderboard helpers (update_user_leaderboard_entries, update_referrer_points) instead of manual leaderboard entry management - Raise CommandError on complete failure to surface to HTTP callers - Comprehensive test suite (16 tests) covering all command paths Database migration note: This command requires the "Uptime" ContributionType to exist. Run the daily uptime workflow after deploying, or manually via: python manage.py add_daily_uptime --verbose Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add POST /api/v1/validators/wallets/daily-uptime/ endpoint protected by IsCronToken authentication. Calls the add_daily_uptime management command and returns success/failure with output details. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Runs at 00:30 UTC daily, triggers the daily-uptime endpoint with CRON_SYNC_TOKEN. Supports manual workflow_dispatch for ad-hoc runs. Setup requirements: - Set CRON_SYNC_TOKEN secret in the 'cron-job' environment - Set API_BASE_URL secret pointing to the production API - The "Uptime" ContributionType must exist in the database - A GlobalLeaderboardMultiplier for "Uptime" must be active Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add validator endpoints to API summary and add_daily_uptime command to common commands section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Creates the "Uptime" ContributionType (slug: uptime, category: validator) and its initial GlobalLeaderboardMultiplier (2.0x) via RunPython migration. Required for the add_daily_uptime command to function. Run after deploy: python manage.py migrate contributions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
add_daily_uptimemanagement command with date range backfill support, bulk operations, and atomic transactionsPOST /api/v1/validators/wallets/daily-uptime/endpoint (IsCronToken-protected) for cron automationDeployment Instructions
1. Run database migration (required)
After deploying, run the migration to create the "Uptime" ContributionType and its 2.0x multiplier:
Migration
0041_create_uptime_contribution_typewill automatically create:2. Verify GitHub Secrets (in
cron-jobenvironment)CRON_SYNC_TOKEN— same token used by the existingsync-validatorsworkflowAPI_BASE_URL— production API base URL (e.g.,https://api.points.genlayer.com)3. Verify the workflow
After merge, manually trigger via GitHub Actions -> "Daily Uptime Points" -> "Run workflow":
Backfilling historical data (if needed)
python manage.py add_daily_uptime --start-date 2026-01-01 --end-date 2026-03-26 --verbose # Add --force to use multiplier=1.0 if no multiplier exists for older dates python manage.py add_daily_uptime --start-date 2026-01-01 --end-date 2026-03-26 --force --verboseTest Coverage
All new code paths have test coverage (16 tests, 100% path coverage).
Pre-Landing Review
No issues found.
Test plan
python manage.py migrate contributionscron-jobenvironment