Skip to content

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

Description

@jagdish-15

The user profile endpoint currently fetches two independent data sources:

  • The latest live profile data from the LeetCode wrapper API (contest rating, global rank, etc.).
  • The user's data file from the data repository, which contains badges, leaderboard ranks, and solved-count history.

Since the historical data is only updated during the scheduled sync, the latest history entry for the current day may lag behind the live profile by up to one sync interval. As a result, the profile page can display today's solved counts using stale values even though fresher values have already been fetched from the live API during the same request.

Proposed Solution

After fetching both data sources:

  • Keep using the historical data file for badges, leaderboard ranks, and previous history.
  • Detect the latest history entry (today's date).
  • Replace only today's easy, medium, and hard solved counts with the live values returned by the LeetCode wrapper API.
  • Leave all previous historical entries unchanged.

This ensures the profile history always reflects the user's latest progress without waiting for the next scheduled sync, while still preserving the existing history structure and metadata.

Expected Outcome

  • Today's solved counts are always up to date on the profile page.
  • Historical entries from previous days remain unchanged.
  • Badges, leaderboard ranks, and historical data continue to be loaded from the data repository.
  • No additional API requests are introduced, since the live profile data is already being fetched for every request.

Affected Files

  • scripts/fetch-user-info.js

Metadata

Metadata

Assignees

Labels

BackendTask mainly involving backendlevel:intermediateIndicates the difficultytype:featureNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions