Skip to content

Use Backend Streak Data for HOT_STREAK Badge #360

Description

@jagdish-15

The HOT_STREAK badge in frontend/js/user/badges.js is currently determined by manually iterating through the user.history array and calculating consecutive active days on the client side. This duplicates logic that is now handled by the backend and introduces unnecessary complexity and edge-case handling.

Proposed Solution

With the backend now exposing the user's streak information (introduced in PR #349), the frontend should use it directly instead of recalculating the streak from the history array.

The existing history traversal logic can be replaced with a simple check:

if (data.streak && data.streak.current >= 7) {
  earnedSet.add("HOT_STREAK");
}

Tasks

  • Remove the manual client-side HOT_STREAK calculation from frontend/js/user/badges.js.
  • Award the badge when data.streak.current >= 7.
  • Verify that the badge is correctly awarded only to users with an active streak of at least 7 days.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions