fix: use live solved counts for today's history entry#283
Conversation
|
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
|
| if (latestEntry && liveSolved) { | ||
| latestEntry.easy = liveSolved.easy; | ||
| latestEntry.medium = liveSolved.medium; | ||
| latestEntry.hard = liveSolved.hard; | ||
| } |
There was a problem hiding this comment.
| 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.
| content: attr(data-tooltip); | ||
| position: absolute; | ||
| bottom: 140%; | ||
| bottom: 140%; /* Default position */ |
There was a problem hiding this comment.
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?
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
easySolved,mediumSolved,hardSolved) from the LeetCode wrapper API.easy,medium, andhardsolved counts with live values.Type of Change
Testing
Test Cases
Checklist
npx prettier --write .before submittingfeature/*branch, not themainbranchScreenshots / Screen Recording
N/A (Backend change)