Bug Description
The streakCount calculation in src/modules/badges/badge.service.ts (lines 213-216) always returns at least 1, even when the user has no activity. This means every user automatically has a "streak" of 1, which is incorrect.
Location
src/modules/badges/badge.service.ts lines 213-216
const streakCount = Math.max(
completedCourseCount > 0 || quizCompletionCount > 0 ? 1 : 0,
1, // This always forces minimum 1!
);
The Problem
The logic is:
- If user has completed courses OR quizzes: streakCount = 1
- Otherwise: streakCount = 0
- Then
Math.max(..., 1) forces the minimum to 1
This means:
- A brand new user with zero activity has a streak of 1
- The streak badge criteria can never be properly evaluated
- A badge requiring "3-day streak" would show progress 1/3 for a user with no activity
Recommended Fix
const streakCount = completedCourseCount > 0 || quizCompletionCount > 0 ? 1 : 0;
Or better, implement actual streak calculation based on consecutive days with activity (which is what the getLearningStats method in user.service.ts does).
Acceptance Criteria
- Remove the
Math.max(..., 1) that forces minimum streak to 1
- A user with no activity should have a streak of 0
- Consider implementing actual consecutive-day streak calculation
Severity
low - Incorrect badge progress display, but doesn't affect core functionality.
Bug Description
The
streakCountcalculation insrc/modules/badges/badge.service.ts(lines 213-216) always returns at least 1, even when the user has no activity. This means every user automatically has a "streak" of 1, which is incorrect.Location
src/modules/badges/badge.service.tslines 213-216The Problem
The logic is:
Math.max(..., 1)forces the minimum to 1This means:
Recommended Fix
Or better, implement actual streak calculation based on consecutive days with activity (which is what the
getLearningStatsmethod in user.service.ts does).Acceptance Criteria
Math.max(..., 1)that forces minimum streak to 1Severity
low - Incorrect badge progress display, but doesn't affect core functionality.