From 8e2e9e304b95de187981a361cd8e36d614840580 Mon Sep 17 00:00:00 2001 From: Yashaswini K P Date: Sun, 19 Jul 2026 20:39:21 +0530 Subject: [PATCH 1/2] fix: resolve HOT_STREAK badge flickering by excluding today's incomplete data --- frontend/js/user/badges.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/js/user/badges.js b/frontend/js/user/badges.js index 7056ee60..80b2aa6f 100644 --- a/frontend/js/user/badges.js +++ b/frontend/js/user/badges.js @@ -20,8 +20,8 @@ async function loadBadges(username) { const earnedSet = new Set(); - if (history.length >= 8) { - const recent = history.slice(-8); + if (history.length >= 9) { + const recent = history.slice(-9, -1); let streak = true; for (let j = 1; j < recent.length; j++) { const todayTotals = recent[j].easy + recent[j].medium + recent[j].hard; From 7655c07c1e9de69b9a82817046518b1d204a820f Mon Sep 17 00:00:00 2001 From: Yashaswini K P Date: Wed, 22 Jul 2026 23:39:23 +0530 Subject: [PATCH 2/2] fix: resolve HOT_STREAK badge flickering and milestone calculation --- frontend/js/user/badges.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/frontend/js/user/badges.js b/frontend/js/user/badges.js index 80b2aa6f..3f5d1d37 100644 --- a/frontend/js/user/badges.js +++ b/frontend/js/user/badges.js @@ -20,19 +20,44 @@ async function loadBadges(username) { const earnedSet = new Set(); - if (history.length >= 9) { - const recent = history.slice(-9, -1); - let streak = true; + if (history.length >= 8) { + const recent = history.slice(-8, -1); + let streak = 0; + let isValid = true; + for (let j = 1; j < recent.length; j++) { const todayTotals = recent[j].easy + recent[j].medium + recent[j].hard; const yesterdayTotals = recent[j - 1].easy + recent[j - 1].medium + recent[j - 1].hard; - if (todayTotals - yesterdayTotals < 1) { - streak = false; + + if (todayTotals - yesterdayTotals >= 1) { + streak++; + } else { + isValid = false; break; } } - if (streak) earnedSet.add("HOT_STREAK"); + + if (isValid) { + const currentDay = history[history.length - 1]; + const previousDay = history[history.length - 2]; + const solvedToday = + currentDay.easy + + currentDay.medium + + currentDay.hard - + (previousDay.easy + previousDay.medium + previousDay.hard) >= + 1; + + if (solvedToday) { + streak++; + } + } else { + streak = 0; + } + + if (streak >= 7) { + earnedSet.add("HOT_STREAK"); + } } if (ranks.overall && parseInt(ranks.overall.change, 10) >= 5) {