Skip to content

Fix/daily streak computation#1

Merged
ldsgroups225 merged 2 commits intomainfrom
fix/daily-streak-computation
Jan 13, 2026
Merged

Fix/daily streak computation#1
ldsgroups225 merged 2 commits intomainfrom
fix/daily-streak-computation

Conversation

@ldsgroups225
Copy link
Copy Markdown
Owner

@ldsgroups225 ldsgroups225 commented Jan 13, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed daily streak computation to increment only upon successful session completion, reducing erroneous streak counts.
  • Documentation

    • Added comprehensive workflow documentation for AI-assisted development, including PRD generation and task management templates.
  • Refactor

    • Centralized streak calculation logic into a shared utility, eliminating redundant implementations across modules.
    • Enhanced streak calculation to support mode-based filtering.

✏️ Tip: You can customize this high-level summary in your review settings.

This commit introduces a new structured workflow for developing features using AI assistants. The workflow is designed to improve clarity, control, and reliability when building complex features with AI.

The new `agent-template/` directory contains markdown files that guide the AI through a step-by-step process:

- `create-prd.md`: A template for generating a Product Requirement Document (PRD) for a new feature.
- `generate-tasks.md`: A template for breaking down the PRD into a detailed, actionable task list for the AI.
- `README.md`: Provides a comprehensive guide on how to use this workflow.

This approach helps in defining the scope, planning the implementation, and iteratively building and verifying the feature, one task at a time.
This commit refactors the daily challenge and streak calculation logic for better accuracy and performance.

Key changes:
- Moves streak calculation to a dedicated `streak.ts` query with comprehensive unit tests.
- Updates the `daily-challenge` server function to use the new streak query, ensuring consistent data.
- Simplifies the `stats` function by removing the outdated streak logic.
- Introduces a new `[feature-name].md` task for tracking.

This improves the maintainability and reliability of the gamification system.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 13, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces an "AI Dev Tasks" workflow template for structured AI-assisted development using PRD-driven task decomposition, along with a refactored daily streak computation that centralizes streak calculation logic into a shared utility with optional mode filtering and removes redundant inline calculations.

Changes

Cohort / File(s) Summary
AI Dev Tasks Workflow Template
agent-template/README.md, agent-template/create-prd.md, agent-template/generate-tasks.md
Introduces workflow documentation for PRD creation, task generation, and execution phases. Defines standardized formats for clarifying questions, PRD structure, and task decomposition with interactive confirmation steps.
Streak Computation Refactoring
apps/user-application/src/core/functions/daily-challenge.ts, apps/user-application/src/core/functions/stats.ts, packages/data-ops/src/queries/streak.ts
Consolidates manual streak calculation logic into a centralized utility. Adds optional mode parameter to streak query functions. Updates daily-challenge and stats modules to use the shared utility, eliminating redundant consecutive-day calculations.
Streak Query Tests
packages/data-ops/src/queries/streak.test.ts
Adds test suite validating streak query construction with mocked drizzle-orm, including filters for completed sessions (endedAt IS NOT NULL, cardsReviewed > 0) and optional mode filtering.
Streak Computation Documentation
tasks/prd-daily-streak-computation.md, tasks/tasks-daily-streak-computation.md
Specifies PRD and task checklist for streak fix, establishing completion-based increment conditions, centralized utility usage, and success metrics for streak calculation reliability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A template to guide the AI's way,
PRDs and tasks in perfect display,
Streaks now computed with clarity,
Shared utilities end redundancy,
Hop forward with tests—hooray! ✨

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a688501 and 030ff6c.

📒 Files selected for processing (9)
  • agent-template/README.md
  • agent-template/create-prd.md
  • agent-template/generate-tasks.md
  • apps/user-application/src/core/functions/daily-challenge.ts
  • apps/user-application/src/core/functions/stats.ts
  • packages/data-ops/src/queries/streak.test.ts
  • packages/data-ops/src/queries/streak.ts
  • tasks/prd-daily-streak-computation.md
  • tasks/tasks-daily-streak-computation.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ldsgroups225 ldsgroups225 merged commit bd4fc14 into main Jan 13, 2026
0 of 3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 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.

2 participants