Skip to content

Comments

Caching content: Caching the user stats and making submission sync to codeforces#132

Merged
aviralsaxena16 merged 10 commits intoOpenLake:mainfrom
aviralsaxena16:Caching_content
Jan 11, 2026
Merged

Caching content: Caching the user stats and making submission sync to codeforces#132
aviralsaxena16 merged 10 commits intoOpenLake:mainfrom
aviralsaxena16:Caching_content

Conversation

@aviralsaxena16
Copy link
Member

@aviralsaxena16 aviralsaxena16 commented Jan 11, 2026

Description

This PR revamps the UI for the Problem of the Day (POTD) page to align it with the "Practice Arena" design language. The primary focus was fixing the header layout issues where the mascot image was forcing unnecessary height, and improving the visual hierarchy of the typography.

Additionally, a dedicated "Empty State" has been added to the leaderboard for days where no users have solved the problem yet.

🔑 Key Changes

1. Header Redesign (Visual Polish)

  • Style Match: Updated the POTD header to strictly follow the "Practice Arena" card style (clean white background, subtle border, left-aligned text).
  • Typography: Implemented the correct font weights (Bold Title, Medium Grey Subtitle, Light Grey Description) and hierarchy.
  • Iconography: Added a 3D-style Calendar/Date icon next to the title to match the design system.

2. Layout Fixes

  • Floating Mascot: The mascot image is now position: absolute. It "pops out" of the container without affecting the header's height or pushing text content down.
  • Grid Adjustment: Adjusted the main grid ratio to 2.5fr 1fr for better spacing between the Problem Description and the Leaderboard.

3. New Features

  • Leaderboard Empty State: Added logic to display nosolve.png with a "Be the first to claim the throne!" message when dailySolvers is empty, replacing the previous text-only placeholder.

📸 Screenshots

Section Description
Header Matches "Practice Arena" style. Image floats on the right. Height is compact.
Leaderboard Shows nosolve.png when empty.

🧪 Testing

  • Verified that the header looks consistent on Desktop (1280px+).
  • Verified that the mascot image hides/fades correctly on Tablet/Mobile to prevent overlap.
  • Tested the "Empty State" by viewing a future date/unsolved problem.

📂 Files Changed

  • styles/POTDpage.module.css: Complete CSS overhaul for .heroSection and .leaderboardCard.
  • pages/POTDPage.tsx: Structural updates to the Hero section DOM and Conditional rendering for the empty state.

Summary by CodeRabbit

Release Notes

  • New Features

    • Redesigned Picture of the Day with Codeforces verification and top solver leaderboard
    • Codeforces integration to sync and verify solved problems automatically
    • Dynamic contests list with platform filters and visual badges
    • Enhanced main dashboard with cached user statistics
  • Style

    • Comprehensive visual updates to question lists, main menu, and challenge cards
    • Improved card layouts and interactive states across the application

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 11, 2026

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

This PR integrates Codeforces submission verification and syncing across the platform, redesigns contest and POTD displays with dual-source data fetching and fallback logic, expands Firebase services for user stats and authentication, and modernizes UI styling and layout across multiple components. It also refactors the questions editor and updates formatting utilities to support markdown-like HTML conversion.

Changes

Cohort / File(s) Summary
Configuration & Dependencies
package.json, tsconfig.json
Added baseline-browser-mapping dependency; changed JSX emission from react-jsx to preserve mode
Codeforces Integration Services
src/services/codeforces.ts, src/services/codeforces_api.ts
New modules exporting async functions to verify Codeforces submissions and fetch user info; includes error handling, input validation, and API response parsing
Firebase Service Expansion
src/services/firebase.ts
Added signupWithGoogle auth, updateUserProfile, getOrUpdateUserStats (with Codeforces API caching and fallback), and multiple Codeforces wrappers (contest count, solved count, rating graph, problems by tags/difficulty, contest history, user search)
Contest API & Data Layer
src/pages/api/contests.ts
Redesigned Contest type (startTime/duration as numbers), added ContestsResponse source field, implemented dual-source fetching (clist.by primary, competeapi.vercel.app fallback) with platform mapping and robust error handling
Contest Display & UI
src/pages/contests-list.tsx, src/common/components/UpcomingContests/UpcomingContests.tsx
Replaced static content with dynamic contest list fetching, added platform filter tabs, platform logo rendering, skeleton loading, fallback warning UI, and local formatting helpers
Contest Styling
src/styles/ContestsList.module.css, src/styles/Contests.module.css
Overhauled ContestsList with new grid/card system, platform badges, shimmer skeleton animation, responsive design; fixed syntax error in Contests.module.css
POTD Enhancement & Verification
src/pages/potd.tsx, src/common/components/MainMenu/MainMenu.tsx
Added Codeforces submission verification flow, transactional Firestore updates for coins/streaks, two-column grid layout with hero section, verifier card UI, dynamic solver display, and new handler functions for CF checks
POTD Styling
src/styles/POTDpage.module.css
Redesigned page structure with hero section, content wrapper, grid-based two-column layout, modernized card and button styling, improved code block formatting, responsive adjustments for smaller viewports
Questions List & Sync
src/common/components/Ques/QuesList.tsx, src/pages/questions/[id].tsx
Replaced checkbox-based tracking with solved-IDs set per rating, integrated CF sync with submission status fetching, added Sync Progress button with spinner, removed API submission flow from editor, simplified rendering logic
Questions Styling
src/common/components/Ques/QuesList.module.css
Expanded container width (1200px → 1600px), introduced Action Bar with sync button, new question item row layout with hover effects, tags and status badges, CF link button styling, responsive column layout for narrow screens
MainMenu Component & Styling
src/common/components/MainMenu/MainMenu.tsx, src/common/components/MainMenu/MainMenu.module.css
Refactored with getOrUpdateUserStats hook, localStorage caching, new POTD card layout with header/title/rating/snippet, action buttons (Solve Challenge and Codeforces), calendar date display; styling adds gradients, shadows, transitions, notification icon hover states, and POTD card redesign
Format Utilities
src/utils/formatDescription.tsx (added), src/utils/formatDescription.ts (removed)
Replaced TypeScript utility with new TSX module exporting formatDescription (markdown-like to HTML conversion), stripHtmlTags, and truncateText helpers

Sequence Diagrams

sequenceDiagram
    participant User
    participant App as Application
    participant CF as Codeforces API
    participant DB as Firestore
    
    User->>App: Click "Verify Submission" (POTD)
    activate App
    App->>CF: Fetch user submissions (last 50)
    activate CF
    CF-->>App: Return submissions list
    deactivate CF
    
    App->>App: Parse problem URL to extract contest/index
    App->>App: Search for matching accepted submission
    
    alt Submission Found & Verified
        App->>DB: Run transaction: update coins, streak, lastSolvedDate
        activate DB
        DB->>DB: Add user to daily solvers sub-collection
        DB-->>App: Transaction committed
        deactivate DB
        App-->>User: Display "Solved" state
    else No Valid Submission
        App-->>User: Show verification failed message
    end
    deactivate App
Loading
sequenceDiagram
    participant App as Application
    participant CLIST as clist.by API
    participant FALLBACK as competeapi API
    participant Response as Client
    
    App->>App: Fetch contests request
    activate App
    App->>CLIST: Request contests with Authorization header
    activate CLIST
    
    alt CLIST Success (HTTP 200)
        CLIST-->>App: Return contest data
        App->>App: Transform to Contest[] with source: "clist"
        App-->>Response: Return {contests, source: "clist"}
    else CLIST Failure
        CLIST-->>App: Error or timeout
        deactivate CLIST
        App->>FALLBACK: Request contests (fallback source)
        activate FALLBACK
        FALLBACK-->>App: Return contest data
        App->>App: Filter by allowed platforms, transform to Contest[]
        App-->>Response: Return {contests, source: "fallback"}
        deactivate FALLBACK
    end
    deactivate App
Loading
sequenceDiagram
    participant User
    participant App as QuesList Component
    participant CF as Codeforces API
    participant DB as Firestore
    
    User->>App: Click "Sync Progress" button
    activate App
    App->>App: Set syncing state, show spinner
    
    App->>CF: Fetch user submissions
    activate CF
    CF-->>App: Return submissions
    deactivate CF
    
    App->>App: Parse CF problem URLs, extract contest/index
    App->>App: Compare with local questions, identify new solves
    
    loop For each new solved problem
        App->>DB: Update user.solvedQuestions[rating] with problem ID
        activate DB
        DB-->>App: Acknowledged
        deactivate DB
        App->>App: Update local solvedIds and progress
    end
    
    App->>App: Clear syncing state
    App-->>User: Display updated progress and status badges
    deactivate App
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested reviewers

  • Jagath-P

Poem

🐰 Hopping through contests with dual sources so bright,
Codeforces verified, submissions held tight,
POTD cards gleaming with solver displays,
Questions now syncing in modern-styled ways,
A rabbit's delight—Firebase and cards in the night! 🌙✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7357c7 and d74ca6a.

⛔ Files ignored due to path filters (9)
  • package-lock.json is excluded by !**/package-lock.json
  • public/images/nosolver.png is excluded by !**/*.png
  • public/images/teacher.png is excluded by !**/*.png
  • public/images/teacher1.png is excluded by !**/*.png
  • public/logos/atcoder.png is excluded by !**/*.png
  • public/logos/codechef.png is excluded by !**/*.png
  • public/logos/codeforces.png is excluded by !**/*.png
  • public/logos/hackerearth.png is excluded by !**/*.png
  • public/logos/leetcode.png is excluded by !**/*.png
📒 Files selected for processing (19)
  • package.json
  • src/common/components/MainMenu/MainMenu.module.css
  • src/common/components/MainMenu/MainMenu.tsx
  • src/common/components/Ques/QuesList.module.css
  • src/common/components/Ques/QuesList.tsx
  • src/common/components/UpcomingContests/UpcomingContests.tsx
  • src/pages/api/contests.ts
  • src/pages/contests-list.tsx
  • src/pages/potd.tsx
  • src/pages/questions/[id].tsx
  • src/services/codeforces.ts
  • src/services/codeforces_api.ts
  • src/services/firebase.ts
  • src/styles/Contests.module.css
  • src/styles/ContestsList.module.css
  • src/styles/POTDpage.module.css
  • src/utils/formatDescription.ts
  • src/utils/formatDescription.tsx
  • tsconfig.json

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.

@github-actions
Copy link

🎉 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

@aviralsaxena16 aviralsaxena16 merged commit ef7817f into OpenLake:main Jan 11, 2026
1 of 3 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.

1 participant