Skip to content

fix: use live solved counts for today's history entry#283

Open
shineetejol9 wants to merge 2 commits into
codepvg:mainfrom
shineetejol9:feature/live-history-counts
Open

fix: use live solved counts for today's history entry#283
shineetejol9 wants to merge 2 commits into
codepvg:mainfrom
shineetejol9:feature/live-history-counts

Conversation

@shineetejol9

Copy link
Copy Markdown
Contributor

Description

This PR updates the user profile endpoint to use the latest solved counts from the live LeetCode API for today's history entry.

Previously, the profile could display stale solved counts for the current day because historical data is only refreshed during the scheduled sync. This change updates only today's history entry with the latest live solved counts while preserving all previous historical records.

Linked Issue

Fixes #265

Changes Made

  • Fetch live solved counts (easySolved, mediumSolved, hardSolved) from the LeetCode wrapper API.
  • Locate today's history entry after loading historical data.
  • Update only today's easy, medium, and hard solved counts with live values.
  • Leave previous history entries unchanged.
  • Keep badges, leaderboard ranks, contest information, and historical data loading behavior unchanged.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Test Cases

  • Verified a user with a history entry for today displays live solved counts.
  • Verified a user without a history entry for today continues to work without any changes.
  • Verified previous historical entries remain unchanged.

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

N/A (Backend change)

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

Comment on lines +90 to +94
if (latestEntry && liveSolved) {
latestEntry.easy = liveSolved.easy;
latestEntry.medium = liveSolved.medium;
latestEntry.hard = liveSolved.hard;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (latestEntry && liveSolved) {
latestEntry.easy = liveSolved.easy;
latestEntry.medium = liveSolved.medium;
latestEntry.hard = liveSolved.hard;
}
if (latestEntry && liveSolved) {
latestEntry.easy = liveSolved.easy;
latestEntry.medium = liveSolved.medium;
latestEntry.hard = liveSolved.hard;
} else if (liveSolved) {
history.push({
date: today,
easy: liveSolved.easy,
medium: liveSolved.medium,
hard: liveSolved.hard,
});
}

This takes care of an edge case where a user visits after midnight but before the next sync runs. Since the date has changed, latestEntry will be null, causing the latest values to be ignored. In that case, we should instead create a new history entry for the current date.

Comment thread frontend/styles/main.css
content: attr(data-tooltip);
position: absolute;
bottom: 140%;
bottom: 140%; /* Default position */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like this file contains changes from one of your previous, unrelated PRs.

Could you cherry-pick only the commit related to this issue and force-push the branch so this PR contains just the intended changes?

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.

Use live solved counts for today's history entry in fetch-user-info.js

2 participants