Skip to content

Issue: Prevent Duplicate or Misaligned Entries in User Profile History Arrays #399

Description

@Yashaswini-K-P

File Name

scripts/sync-leaderboard.js

Problem

In updateUserDataAsync, the history update checks for existing entries using dateStr (YYYY-MM-DD). However, if the sync script runs multiple times across different time zones or if historical file indexing shifts due to timing discrepancies, multiple entries for the same date can occasionally be created or overwrite issues occur without robust deduplication.

Proposed Solution

Strengthen the history entry check by ensuring strict uniqueness based on date and adding a validation filter before sorting to eliminate duplicate entries for the same calendar date.

Implementation Details

  • Deduplication Logic: Before writing the updated history array back to disk, filter out or consolidate duplicate entries matching the same date string:
    const uniqueHistory = Array.from(
      new Map(history.map(item => [item.date, item])).values()
    );

Metadata

Metadata

Labels

BackendTask mainly involving backendtype:bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions