fix: resolve issues #360, #361, #362 - grading retries, stale leaderboard, idempotent badges - #499
Open
eulami wants to merge 1 commit into
Conversation
…ckDash-Studios#362 - grading retries, stale leaderboard, idempotent badges Closes BlockDash-Studios#360 - add grading retries with backoff for external evaluation providers Closes BlockDash-Studios#361 - fix stale leaderboard rank updates during high-volume submissions Closes BlockDash-Studios#362 - add conflict-safe, idempotent badge awarding rules Issue BlockDash-Studios#360: - Add config-driven retry backoff env vars (GRADING_MAX_RETRIES, GRADING_RETRY_BASE_DELAY_MS, GRADING_RETRY_MAX_DELAY_MS) - Replace hardcoded backoff in GradingJobService with configurable params - Add notification on permanent grading failure via NotificationsService - Integrate ChallengesService with GradingJobService for retries Issue BlockDash-Studios#361: - Add cache with configurable TTL to LeaderboardService - Add markStale() for real-time invalidation on new submissions - Build leaderboard from real SubmissionService data instead of static sample - Add time-range filtering for daily/weekly/monthly/allTime scopes Issue BlockDash-Studios#362: - Add atomic dedup set for O(1) conflict-safe badge duplicate detection - Make awardBadge() idempotent (silent no-op on duplicates) - Fire in-app notification + BADGE_EARNED analytics event on first award - Wire BadgesService into RewardsService for streak/level milestone badges
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.
Resolve issues #360, #361, #362 — Grading retries, stale leaderboard, idempotent badges
Issues Closed
Summary of Changes
Issue #360 — Grading retries with backoff
Problem: External graders occasionally fail transiently. Submissions were failing immediately without retry.
Solution:
config.module.ts: Added env var schema forGRADING_MAX_RETRIES,GRADING_RETRY_BASE_DELAY_MS,GRADING_RETRY_MAX_DELAY_MSwith sensible defaults.grading-job.service.ts: Replaced hardcoded backoff with config-driven exponential backoff capped atmaxDelayMs. AddednotifyGradingFailure()to send in-app notifications when a grading job permanently exhausts all retries.challenges.service.ts: AddedevaluateWithRetry()method that enqueues failed external evaluations intoGradingJobServicefor retry instead of immediately failing.notifications.service.ts: AddedsendGradingFailureAlert()method respecting user preference.Issue #361 — Stale leaderboard rank updates
Problem: Leaderboard displayed stale/outdated scores using static sample data with no update mechanism.
Solution:
leaderboard.service.ts: Added configurable cache withLEADERBOARD_CACHE_TTL_MS(default 30s). AddedmarkStale()method.buildLeaderboard()now uses realSubmissionServicedata with time-range filtering.Issue #362 — Conflict-safe, idempotent badge awarding
Problem: Badge issuance could create duplicates or inconsistent state when the same achievement was processed multiple times concurrently.
Solution:
badges.service.ts: AddedawardedBadgeSetfor O(1) atomic conflict detection.awardBadge()is now idempotent: duplicate calls silently return existing badges. On first award, fires in-app notification +BADGE_EARNEDanalytics event.rewards.service.ts: Integrates badge awarding on streak/level milestones.Module Wiring
challenges.module.ts,jobs.module.ts,badges.module.ts,rewards.module.ts,leaderboard.module.ts, andapp.module.tswith proper module imports.Validation