Skip to content

[Backend] Add Inactivity Metadata Tracking #175

@Yashaswini-K-P

Description

@Yashaswini-K-P

Description

Before we can optimize our synchronization workflow, the system needs a way to identify stale user profiles. Currently, we have no concept of when a user was last active.

This issue lays the foundational groundwork by introducing two tracking metadata fields—lastActive (an ISO timestamp) and status ("active" | "inactive")—directly into the overall.json data file.


Execution Plan:

I will implement this tracking logic directly inside scripts/sync-leaderboard.js using the following workflow:

1. Read and State Preservation

  • Load the existing overall.json at the start of the script execution.
  • Ensure that for every user processed, their existing lastActive and status values are read into memory so they aren't accidentally wiped or overwritten during the sync loop.

2. Live Activity Detection Loop

For every user fetched during the sync cycle, the script will compare their newly fetched totalSolved count against the totalSolved count currently stored in overall.json:

  • Scenario A: Total Solved Count Has Increased 📈

    • This confirms recent activity.
    • Update lastActive to the current timestamp (new Date().toISOString()).
    • Set status to "active".
  • Scenario B: Total Solved Count is Unchanged ⏳

    • Calculate the delta time: Current Time - user.lastActive.
    • If a user doesn't have a lastActive timestamp yet, default it to the current time to establish a baseline.
    • If the calculated time elapsed exceeds 90 days, change their status to "inactive".
    • Otherwise, leave their status as "active".

3. File Write Back

  • Safely stringify and write the updated user array back to overall.json, ensuring all previous data structures remain completely intact alongside the new metadata fields.

Pls Assign this to me , I would love to work on it .

Metadata

Metadata

Labels

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions