feat: Use live solved counts for today's history entry in fetch-user-info.js (#265) - #339
feat: Use live solved counts for today's history entry in fetch-user-info.js (#265)#339yashvi-3106 wants to merge 1 commit into
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
|
| @@ -85,6 +91,25 @@ async function fetchUserInfo(username) { | |||
| history = Array.isArray(history) ? history : []; | |||
| history.sort((a, b) => new Date(a.date) - new Date(b.date)); | |||
There was a problem hiding this comment.
Could you move this sorting line below the logic where we insert today's count? While today's entry will technically always be the most recent date, it's generally safer and better practice to sort the array after all insertions or modifications have been made. That way the data is guaranteed to be in the correct order regardless of how it's constructed in the future.
|
@yashvi-3106 Are you still planning to continue working on this? |
Description
Previously, the user profile page loaded stale solved count metrics for the current day because historical user data is only updated during the scheduled sync interval (every 15 minutes).
This PR updates the
/api/user/:usernameendpoint to extract live solved counts (easySolved,mediumSolved,hardSolved) from the LeetCode wrapper API and dynamically overwrite (or insert) today's history entry with these live values.Linked Issue
Fixes #265
Changes Made
fetchUserInfo()inscripts/fetch-user-info.jsto extracteasySolved,mediumSolved, andhardSolvedcounts from the wrapper API response.YYYY-MM-DDdate matching).Type of Change
Testing
Checklist
npx prettier --write .before submittingfeature/*branch, not themainbranch