Skip to content

Comments

feat: daily challenge and streak system#177

Merged
Mkalbani merged 2 commits intoMindFlowInteractive:mainfrom
OSEH-svg:daily-challenge
Feb 22, 2026
Merged

feat: daily challenge and streak system#177
Mkalbani merged 2 commits intoMindFlowInteractive:mainfrom
OSEH-svg:daily-challenge

Conversation

@OSEH-svg
Copy link
Contributor

Description

Closes #148

This PR implements the requested Daily Challenge and Streak Tracking System for the backend API. It establishes an automated @nestjs/schedule cron job that rotates the active puzzle daily while incorporating comprehensive streak increments, grace period allowances, and dynamic bonus point rewarding systems.

Features Added

  • Database Schemata:
    • DailyChallenge: Represents a puzzle specific to a UTC day with a scaled difficulty modifier and an explicit active flag.
    • DailyChallengeCompletion: A junction entity tracking a user's completion data, including individual score, time spent, and streak bonuses awarded.
  • Rotation Cron Job:
    • Selects rotating puzzles daily based on the weekday (e.g., Easy on Mon/Tue, Medium on Wed/Thu, Hard on Fri, Expert on Sat/Sun).
    • Filters out recently used puzzles (last 30 days) to guarantee a diverse play experience.
  • Streak & Bonus System:
    • Leverages the existing UserStreak entity. A continuous completion record increments the currentStreak resulting in increasing point multiplier rewards (e.g. +5% extra points per consecutive day, capping at 50% total bonus limit).
    • Automatically zeroes the streak history on a missed day unless rescued by the player's active streakRecoveryGracePeriodEnd.
  • REST Endpoints:
    • GET /daily-challenges/today - Retrieve the active daily puzzle and completion status.
    • POST /daily-challenges/:id/complete - Submits scores and returns active streaks + bonus points awarded.
    • GET /daily-challenges/history - Fetches the last 30 puzzle completions.

Testing

Comprehensive unit testing functionality built within Jest:

  • should create a new streak on first completion
  • should increment streak when completed on consecutive days
  • should reset streak when a day is missed without a grace period
  • should maintain streak when a day is missed but within grace period

Self-Review Checklist

  • Code strictly matches all requirements mapped out in issue Daily Challenge and Streak System #148.
  • Unrelated code, folders, variables, and formats were not refactored or 'cleaned up'.
  • No dependencies were modified outside of standard NextJS behavior.
  • Testing verifiably handles logic for Streak flow boundaries.
  • Codebase compilation runs cleanly for daily-challenges.

@Mkalbani Mkalbani merged commit 60e06c0 into MindFlowInteractive:main Feb 22, 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.

Daily Challenge and Streak System

2 participants