Skip to content

Issue: Optimize Timeframe Lookup Complexity Using a Map #407

Description

@Yashaswini-K-P

File Name

scripts/sync-leaderboard.js

Problem

Inside processTimeframe, the script uses .findIndex() inside a loop to find previous user data:

const previousIndex = previousData.findIndex((obj) => obj.id === item.id); 

Scanning an array repeatedly inside loops leads to $O(N^2)$ inefficiency as the student user base scales up.

Proposed Solution

Convert the previousData array into a Map before chunk processing to ensure $O(1)$ lookups.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions