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()
);
File Name
scripts/sync-leaderboard.jsProblem
In
updateUserDataAsync, the history update checks for existing entries usingdateStr(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
dateand adding a validation filter before sorting to eliminate duplicate entries for the same calendar date.Implementation Details
datestring: