Skip to content

Modified POTD Section#175

Merged
aviralsaxena16 merged 2 commits into
OpenLake:mainfrom
Jaswanth-Kumar-2007:KJK
Jun 22, 2026
Merged

Modified POTD Section#175
aviralsaxena16 merged 2 commits into
OpenLake:mainfrom
Jaswanth-Kumar-2007:KJK

Conversation

@Jaswanth-Kumar-2007

@Jaswanth-Kumar-2007 Jaswanth-Kumar-2007 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

First Issue -Author : @Jaswanth-Kumar-2007

Modified POTD Section for Weekly Leaderboard List as per Total Listing

Summary by CodeRabbit

  • Bug Fixes

    • Fixed weekly solve counting logic to ensure accurate leaderboard rankings
  • UI Updates

    • Rebranded weekly leaderboard section to "LeaderBoard Top 🎉"

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@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.

@github-actions

Copy link
Copy Markdown

🎉 Thanks for Your Contribution to CanonForces! ☺️

We'll review it as soon as possible. In the meantime, please:

  • ✅ Double-check the file changes.
  • ✅ Ensure that all commits are clean and meaningful.
  • ✅ Link the PR to its related issue (e.g., Closes #123).
  • ✅ Resolve any unaddressed review comments promptly.

💬 Need help or want faster feedback?
Join our Discord 👉 CanonForces Discord

Thanks again for contributing 🙌 – @Jaswanth-Kumar-2007!
cc: @aviralsaxena16

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Jaswanth-Kumar-2007, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d155d545-015f-4c4b-8e7e-96d0354cc697

📥 Commits

Reviewing files that changed from the base of the PR and between 78efa37 and e594afe.

📒 Files selected for processing (1)
  • src/pages/potd.tsx

Walkthrough

src/pages/potd.tsx changes the weekly leaderboard Firestore query from filtering by lastWeeklyResetDate to weeklyPotdSolves >= 1. The markAsSolved transaction removes the week-reset branching and unconditionally increments weeklyPotdSolves. The weekly sidebar heading is renamed from "Weekly Top" to "LeaderBoard Top 🎉".

Changes

POTD Weekly Leaderboard and Solve Counting

Layer / File(s) Summary
Interfaces, helpers, and state initialization
src/pages/potd.tsx
Solver, Problem, UserData interfaces, getLocalDateString/getStartOfWeek helpers, POTDPage state, and Firebase auth listener are replaced with no behavioral change.
Weekly leaderboard and daily submission Firestore listeners
src/pages/potd.tsx
Weekly query switched to where("weeklyPotdSolves", ">=", 1) sorted by weeklyPotdSolves; daily potd_submissions listener uses setDoc(..., { merge: true }) and maps/sorts solvers by solvedAt.
markAsSolved transaction and CF submission handler
src/pages/potd.tsx
markAsSolved now computes weeklyPotdSolves as (currentUserData.weeklyPotdSolves || 0) + 1 unconditionally, removing the prior week-reset branch. handleCheckCFSubmission control flow is unchanged.
Render: weekly sidebar heading
src/pages/potd.tsx
Weekly solver sidebar heading changed from "Weekly Top" to "LeaderBoard Top 🎉"; all other layout and data bindings are unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • OpenLake/canonforces#174: Modifies the same markAsSolved Firestore transaction and weekly solve counting logic in src/pages/potd.tsx, overlapping directly with this PR's changes.

Poem

🐇 Hippity-hop, the week starts fresh,
No reset branching to enmesh!
weeklyPotdSolves just adds one more,
The leaderboard shines with a 🎉 at its core.
Query by solves, not dates of old—
A cleaner count, a tale retold!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete; it lacks most required sections including detailed changes, problem/solution explanation, testing evidence, and proper use of the provided template structure. Follow the PR template by adding detailed sections: Changes Introduced (Added/Fixed/Updated/Removed), Why This Change (Problem/Solution/Impact), Testing checklist with manual test cases, and Documentation Updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Modified POTD Section' is vague and overly generic, using non-descriptive terms that don't convey the specific nature of the changes (weekly leaderboard logic and data source updates). Use a more specific title that describes the main change, such as 'Update weekly leaderboard query logic and verification counting' or 'Change weekly top leaderboard data source and increment behavior'.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fbc12169-9814-477d-bb2e-3809cb2cf4f8

📥 Commits

Reviewing files that changed from the base of the PR and between 0c4419a and 78efa37.

📒 Files selected for processing (1)
  • src/pages/potd.tsx

Comment thread src/pages/potd.tsx
Comment on lines +107 to +126
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

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.

Suggested change
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.

Comment thread src/pages/potd.tsx
Comment on lines +199 to +216
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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.

Comment thread src/pages/potd.tsx
@aviralsaxena16 aviralsaxena16 merged commit 2179602 into OpenLake:main Jun 22, 2026
1 of 2 checks passed
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