Modified POTD Section#175
Conversation
|
@Jaswanth-Kumar-2007 is attempting to deploy a commit to the aviralsaxena16's projects Team on Vercel. A member of the Team first needs to authorize it. |
🎉 Thanks for Your Contribution to CanonForces!
|
|
Warning Review limit reached
More reviews will be available in 52 minutes and 21 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. Walkthrough
ChangesPOTD Weekly Leaderboard and Solve Counting
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pages/potd.tsx`:
- Around line 386-390: The JavaScript comment (`// Changed the Name of the
Leaderboard Weekly Top to Leaderboard Top 🎉`) placed directly within JSX
children between the closing div tag and the opening div with
className={styles.sidebarCard} uses invalid syntax. Either remove this comment
entirely since the change is already documented in version control, or convert
it to proper JSX comment syntax using curly braces and asterisks format to wrap
the comment text if you need to keep it for inline documentation.
- Around line 199-216: The lastWeeklyResetDate field is being written to the
database in the transaction.set call on line 216, but the conditional logic that
checks this field to reset the weekly counter (previously commented out around
line 205) has been removed. This creates dead data. Either remove the
lastWeeklyResetDate write from the transaction.set statement entirely if an
all-time counter is intended, or restore the conditional check for
lastWeeklyResetDate equality with currentStartOfWeek before calculating
newWeeklySolves to properly reset the weekly counter when a new week begins.
- Around line 107-126: The weekly leaderboard is broken because the query for
weeklyQ filters only by weeklyPotdSolves >= 1 without filtering by the week, and
the currentStartOfWeek variable is computed but never used. You must choose one
of two approaches: (1) If this should be an all-time leaderboard, rename the
weeklyPotdSolves field and all related UI references (such as
setTopWeeklySolvers and any component labels) to reflect "total" instead of
"weekly", and remove the unused currentStartOfWeek variable; (2) If this should
remain truly weekly, restore the week-reset logic in the markAsSolved function
to reset weeklyPotdSolves on a new week, then update the weeklyQ query to
include both the weeklyPotdSolves >= 1 condition AND a filter on
lastWeeklyResetDate equal to currentStartOfWeek to ensure only users who solved
in the current week appear on the leaderboard.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| const currentStartOfWeek = getStartOfWeek(new Date()); | ||
|
|
||
| const yesterday = new Date(); | ||
| yesterday.setDate(yesterday.getDate() - 1); | ||
| const yesterdayStr = getLocalDateString(yesterday); | ||
| // const weeklyQ = query( | ||
| // collection(db, "users"), | ||
| // where("lastWeeklyResetDate", "==", currentStartOfWeek) | ||
| // ); | ||
|
|
||
| const newStreak = currentUserData.lastSolvedDate === yesterdayStr ? (currentUserData.streak || 0) + 1 : 1; | ||
| // Changes for Weekly POTD Listing Based on the WeeklyPOTD count > 0 | ||
|
|
||
| const currentStartOfWeek = getStartOfWeek(new Date()); | ||
| const newWeeklySolves = currentUserData.lastWeeklyResetDate === currentStartOfWeek ? (currentUserData.weeklyPotdSolves || 0) + 1 : 1; | ||
|
|
||
| const resolvedUsername = | ||
| userData.username || | ||
| currentUser.displayName || | ||
| (currentUser.email ? currentUser.email.split("@")[0] : "User"); | ||
|
|
||
| transaction.set( | ||
| userRef, | ||
| { | ||
| coins: (currentUserData.coins || 0) + 50, totalCoins: (currentUserData.totalCoins || 0) + 50, | ||
| streak: newStreak, lastSolvedDate: todayDate, weeklyPotdSolves: newWeeklySolves, lastWeeklyResetDate: currentStartOfWeek, | ||
| const weeklyQ = query( | ||
| collection(db, "users"), | ||
| where("weeklyPotdSolves", ">=", 1) | ||
| ); | ||
|
|
||
| const unsubWeekly = onSnapshot( | ||
| weeklyQ, | ||
| (snap: any) => { | ||
| let solvers = snap.docs.map((d: any) => ({ ...d.data(), uid: d.id } as UserData)); | ||
| solvers.sort((a: UserData, b: UserData) => (b.weeklyPotdSolves || 0) - (a.weeklyPotdSolves || 0)); | ||
| setTopWeeklySolvers(solvers); |
There was a problem hiding this comment.
Weekly leaderboard logic is broken—counter never resets, query has no week filter.
The query now fetches all users with weeklyPotdSolves >= 1 regardless of when they solved. Combined with the markAsSolved change that unconditionally increments weeklyPotdSolves (never resets on new week), this becomes an all-time leaderboard, not weekly.
Additionally, currentStartOfWeek on line 107 is now dead code—computed but unused.
If the intent is an all-time leaderboard: rename the field and UI references from "weekly" to something like totalPotdSolves.
If the intent is truly weekly: restore the week-reset logic in markAsSolved and filter by lastWeeklyResetDate:
🔧 Proposed fix to restore weekly semantics
- const weeklyQ = query(
- collection(db, "users"),
- where("weeklyPotdSolves", ">=", 1)
- );
+ const weeklyQ = query(
+ collection(db, "users"),
+ where("lastWeeklyResetDate", "==", currentStartOfWeek)
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const currentStartOfWeek = getStartOfWeek(new Date()); | |
| const yesterday = new Date(); | |
| yesterday.setDate(yesterday.getDate() - 1); | |
| const yesterdayStr = getLocalDateString(yesterday); | |
| // const weeklyQ = query( | |
| // collection(db, "users"), | |
| // where("lastWeeklyResetDate", "==", currentStartOfWeek) | |
| // ); | |
| const newStreak = currentUserData.lastSolvedDate === yesterdayStr ? (currentUserData.streak || 0) + 1 : 1; | |
| // Changes for Weekly POTD Listing Based on the WeeklyPOTD count > 0 | |
| const currentStartOfWeek = getStartOfWeek(new Date()); | |
| const newWeeklySolves = currentUserData.lastWeeklyResetDate === currentStartOfWeek ? (currentUserData.weeklyPotdSolves || 0) + 1 : 1; | |
| const resolvedUsername = | |
| userData.username || | |
| currentUser.displayName || | |
| (currentUser.email ? currentUser.email.split("@")[0] : "User"); | |
| transaction.set( | |
| userRef, | |
| { | |
| coins: (currentUserData.coins || 0) + 50, totalCoins: (currentUserData.totalCoins || 0) + 50, | |
| streak: newStreak, lastSolvedDate: todayDate, weeklyPotdSolves: newWeeklySolves, lastWeeklyResetDate: currentStartOfWeek, | |
| const weeklyQ = query( | |
| collection(db, "users"), | |
| where("weeklyPotdSolves", ">=", 1) | |
| ); | |
| const unsubWeekly = onSnapshot( | |
| weeklyQ, | |
| (snap: any) => { | |
| let solvers = snap.docs.map((d: any) => ({ ...d.data(), uid: d.id } as UserData)); | |
| solvers.sort((a: UserData, b: UserData) => (b.weeklyPotdSolves || 0) - (a.weeklyPotdSolves || 0)); | |
| setTopWeeklySolvers(solvers); | |
| const currentStartOfWeek = getStartOfWeek(new Date()); | |
| // const weeklyQ = query( | |
| // collection(db, "users"), | |
| // where("lastWeeklyResetDate", "==", currentStartOfWeek) | |
| // ); | |
| // Changes for Weekly POTD Listing Based on the WeeklyPOTD count > 0 | |
| const weeklyQ = query( | |
| collection(db, "users"), | |
| where("lastWeeklyResetDate", "==", currentStartOfWeek) | |
| ); | |
| const unsubWeekly = onSnapshot( | |
| weeklyQ, | |
| (snap: any) => { | |
| let solvers = snap.docs.map((d: any) => ({ ...d.data(), uid: d.id } as UserData)); | |
| solvers.sort((a: UserData, b: UserData) => (b.weeklyPotdSolves || 0) - (a.weeklyPotdSolves || 0)); | |
| setTopWeeklySolvers(solvers); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/potd.tsx` around lines 107 - 126, The weekly leaderboard is broken
because the query for weeklyQ filters only by weeklyPotdSolves >= 1 without
filtering by the week, and the currentStartOfWeek variable is computed but never
used. You must choose one of two approaches: (1) If this should be an all-time
leaderboard, rename the weeklyPotdSolves field and all related UI references
(such as setTopWeeklySolvers and any component labels) to reflect "total"
instead of "weekly", and remove the unused currentStartOfWeek variable; (2) If
this should remain truly weekly, restore the week-reset logic in the
markAsSolved function to reset weeklyPotdSolves on a new week, then update the
weeklyQ query to include both the weeklyPotdSolves >= 1 condition AND a filter
on lastWeeklyResetDate equal to currentStartOfWeek to ensure only users who
solved in the current week appear on the leaderboard.
| const currentStartOfWeek = getStartOfWeek(new Date()); | ||
|
|
||
| // const newWeeklySolves = currentUserData.lastWeeklyResetDate === currentStartOfWeek ? (currentUserData.weeklyPotdSolves || 0) + 1 : 1; | ||
|
|
||
| // Changes for the Weekly Count Addition | ||
|
|
||
| const newWeeklySolves = (currentUserData.weeklyPotdSolves || 0) + 1; | ||
|
|
||
| const resolvedUsername = | ||
| userData.username || | ||
| currentUser.displayName || | ||
| (currentUser.email ? currentUser.email.split("@")[0] : "User"); | ||
|
|
||
| transaction.set( | ||
| userRef, | ||
| { | ||
| coins: (currentUserData.coins || 0) + 50, totalCoins: (currentUserData.totalCoins || 0) + 50, | ||
| streak: newStreak, lastSolvedDate: todayDate, weeklyPotdSolves: newWeeklySolves, lastWeeklyResetDate: currentStartOfWeek, |
There was a problem hiding this comment.
lastWeeklyResetDate is written but never used—weekly reset logic removed.
Line 216 still writes lastWeeklyResetDate: currentStartOfWeek, but line 205 no longer checks it to reset the counter. This field is now effectively dead data.
Either remove the write entirely (if all-time is intended) or restore the conditional reset:
🔧 If weekly reset is intended
- const newWeeklySolves = (currentUserData.weeklyPotdSolves || 0) + 1;
+ const newWeeklySolves = currentUserData.lastWeeklyResetDate === currentStartOfWeek
+ ? (currentUserData.weeklyPotdSolves || 0) + 1
+ : 1;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/potd.tsx` around lines 199 - 216, The lastWeeklyResetDate field is
being written to the database in the transaction.set call on line 216, but the
conditional logic that checks this field to reset the weekly counter (previously
commented out around line 205) has been removed. This creates dead data. Either
remove the lastWeeklyResetDate write from the transaction.set statement entirely
if an all-time counter is intended, or restore the conditional check for
lastWeeklyResetDate equality with currentStartOfWeek before calculating
newWeeklySolves to properly reset the weekly counter when a new week begins.
First Issue -Author : @Jaswanth-Kumar-2007
Modified POTD Section for Weekly Leaderboard List as per Total Listing
Summary by CodeRabbit
Bug Fixes
UI Updates