Skip to content

Fixed some bugs related to POTD page#174

Merged
Ashish-Kumar-Dash merged 2 commits into
OpenLake:mainfrom
aviralsaxena16:POTD-fixes-2
Jun 9, 2026
Merged

Fixed some bugs related to POTD page#174
Ashish-Kumar-Dash merged 2 commits into
OpenLake:mainfrom
aviralsaxena16:POTD-fixes-2

Conversation

@aviralsaxena16

@aviralsaxena16 aviralsaxena16 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Bugs like streak update failure , coin update failure submission race condition

Summary by CodeRabbit

  • Bug Fixes

    • Improved authentication handling to ensure accurate user session information
    • Enhanced Codeforces submission verification with better validation and error messaging
  • New Features

    • Redesigned mission header with improved layout and detail presentation
    • Added stats panel displaying coins, streak tracking, and verification controls
    • Enhanced daily and weekly leaderboard display with improved formatting

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

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

github-actions Bot commented Jun 9, 2026

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 🙌 – @aviralsaxena16!
cc: @aviralsaxena16

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aviralsaxena16, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 55 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

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

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

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: 675662d2-aba8-468e-8fa1-68b695a5986d

📥 Commits

Reviewing files that changed from the base of the PR and between b4076db and 6babaff.

📒 Files selected for processing (2)
  • src/pages/potd.tsx
  • src/utils/formatDescription.tsx

Walkthrough

The POTD page is refactored to use React state for current user auth status, backfill daily submission data when missing, throw errors on invalid verification, and restructure mission header and action UI to display stats and verification controls with updated sidebar empty-state messages.

Changes

POTD Page Auth State and Verification Flow

Layer / File(s) Summary
Auth State Listener and Imports
src/pages/potd.tsx
Firestore/Auth imports are reorganized to add onAuthStateChanged. A new currentUser React state initialized from auth.currentUser is synchronized via useEffect listener, and getLocalDateString date formatting is updated for consistency.
POTD and Leaderboard Data Fetching
src/pages/potd.tsx
POTD document fetch result assignment is condensed. Weekly leaderboard onSnapshot handler removes async signature and simplifies snapshot mapping while preserving sort and state update behavior.
Daily Submissions Backfill and Verification Logic
src/pages/potd.tsx
Daily submissions effect now derives solvers from snapshot data, backfills missing documents via setDoc with merge: true, sorts by solvedAt, and derives userSolved from currentUser. User subscription depends on currentUser. markAsSolved becomes a useCallback that throws on missing session or duplicate verification. handleCheckCFSubmission uses currentUser, validates Codeforces URL, calls markAsSolved, and shows toast outcomes.
Mission Header and Action Area UI
src/pages/potd.tsx
Mission header section is reworked with updated description, difficulty, and rating rendering. New action area adds coins/streak stats grid and refactors button group to display solved banner or Codeforces verification button with loading state, plus optional external link.
Daily and Weekly Solvers Sidebar Updates
src/pages/potd.tsx
Daily solvers sidebar casts solvedAt to Date and preserves fallback messaging. Weekly solvers sidebar updates "Day"/"Days" plural formatting and displays "Starting a new week!" when no solvers exist.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • Jagath-P

Poem

🐰 A rabbit hops through POTD's refactored way,
Where auth now listens, fresh as morning's day,
Data backfills true, and solvers sort with care,
The mission shines anew in UI's fair repair! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is severely incomplete, containing only a brief comma-separated list of bug names without following the required template structure, missing sections like reasoning, testing, and documentation. Expand the description to follow the template: add detailed problem statements, explain solutions, describe testing performed, include before/after screenshots if applicable, and complete the checklist items.
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 'Fixed some bugs related to POTD page' is overly vague and generic, using the non-specific term 'some bugs' without indicating what those bugs are or their specific nature. Provide a more specific title that identifies the key bugs fixed, such as 'Fix streak/coin updates and submission race condition on POTD page' to convey meaningful information.
✅ 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: 5

🤖 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 233-239: checkCodeforcesSubmission currently returns true for any
historical AC, letting users claim today's POTD; update the verification to
require an accepted submission timestamp within the target day before awarding
and messaging. Modify checkCodeforcesSubmission (or create a new helper like
checkCodeforcesSubmissionOnDate) to fetch the user's submissions for the
contest/problem and confirm at least one accepted submission whose
epoch/timezone-normalized date equals the POTD date (use startOfDay/endOfDay
bounds in the app's timezone or UTC as appropriate), then call markAsSolved and
show the success toast only when that date-limited check passes; also adjust the
success/error messages to accurately reflect "found today" vs historical ACs.
- Around line 187-190: The fallback for resolvedUsername can produce an array
because currentUser.email.split("@") returns string[]; change the fallback to
produce a string (e.g., use currentUser.email?.split("@")[0] or another
string-safe expression) so resolvedUsername is always a string; update the
assignment that uses userData.username, currentUser.displayName, and
currentUser.email to ensure resolvedUsername is a string before writing into
solvers[uid].username and downstream uses.
- Around line 174-176: The early-return when currentUserData.lastSolvedDate ===
todayDate should throw an error instead so the transaction resolves as a
rejection and the caller (handleCheckCFSubmission) won't display the success
toast; replace the return with a thrown Error (or custom error type/message like
"Already solved today") in the function where currentUserData and lastSolvedDate
are checked, ensure callers (handleCheckCFSubmission and any callers of
markAsSolved) catch this error and handle it without showing the "progress
saved" toast.
- Around line 145-157: When currentUser becomes null the effect returns early
but doesn't clear derived state; update the effect to explicitly reset
setUserData and setCfUsername to their signed-out defaults when currentUser is
falsy (e.g. setUserData({coins: 0, streak: 0, lastSolvedDate: null, username:
""}) and setCfUsername("")), then return; otherwise proceed to create the
userRef, subscribe via onSnapshot and return the unsubscribe; ensure you
reference currentUser, setUserData, setCfUsername and the onSnapshot/unsubscribe
logic in the change.
- Line 295: The code renders untrusted Firestore content via
dangerouslySetInnerHTML using formatDescription(fullDesc) without sanitization;
update the rendering pipeline to sanitize or escape input before passing it to
dangerouslySetInnerHTML — for example, import a sanitizer like DOMPurify (or
sanitize-html), run DOMPurify.sanitize(...) on the raw problem.description (or
on the HTML produced by formatDescription) with an explicit
allowedTags/allowedAttributes policy, and then use the sanitized string in the
div (the symbols to change are formatDescription, fullDesc, and the JSX div with
dangerouslySetInnerHTML); ensure you do not call dangerouslySetInnerHTML with
unsanitized user content and add unit/CI checks if available.
🪄 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: e0fb3dcf-3fad-4efa-93d0-9992499fd3eb

📥 Commits

Reviewing files that changed from the base of the PR and between 60a0c31 and b4076db.

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

Comment thread src/pages/potd.tsx
Comment thread src/pages/potd.tsx
Comment thread src/pages/potd.tsx Outdated
Comment thread src/pages/potd.tsx
Comment on lines +233 to +239
const hasSolved = await checkCodeforcesSubmission(usernameToCheck, contestId, problemIndex);

if (hasSolved) {
await markAsSolved(); // If this fails, it jumps to the catch block and WON'T show success
toast.success("🎉 Verified! Solution found and progress saved!");
} else {
toast.error("No accepted submission found today.");

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

Verification still accepts historical Codeforces ACs.

This branch awards today's streak/coins based on checkCodeforcesSubmission(), but that helper only checks whether the user has ever AC'd the contest/problem. A user with an old accepted submission can still claim today's POTD, and the “found today” messaging is inaccurate.

🤖 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 233 - 239, checkCodeforcesSubmission
currently returns true for any historical AC, letting users claim today's POTD;
update the verification to require an accepted submission timestamp within the
target day before awarding and messaging. Modify checkCodeforcesSubmission (or
create a new helper like checkCodeforcesSubmissionOnDate) to fetch the user's
submissions for the contest/problem and confirm at least one accepted submission
whose epoch/timezone-normalized date equals the POTD date (use
startOfDay/endOfDay bounds in the app's timezone or UTC as appropriate), then
call markAsSolved and show the success toast only when that date-limited check
passes; also adjust the success/error messages to accurately reflect "found
today" vs historical ACs.

Comment thread src/pages/potd.tsx
@Ashish-Kumar-Dash
Ashish-Kumar-Dash merged commit 0c4419a into OpenLake:main Jun 9, 2026
6 of 7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 17, 2026
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