Description
The analyze-inactivity.js script fetches LeetCode profile data for all registered users but is missing three safeguards that sync-leaderboard.js already implements:
- No retry logic on API failure — if a request fails, the user is silently skipped.
- 50-user concurrency (vs 20 in sync-leaderboard) — higher risk of rate limiting.
- No fallback to stale data — if the API fails, the user is simply skipped and not included in the output.
Affected Code
const CONCURRENCY_LIMIT = 50; // sync-leaderboard.js uses 20
// No retry interceptor configured (sync-leaderboard.js has one)
async function fetchData(url) {
try {
const res = await axios.get(url, { timeout: 15000 });
return res.data;
} catch (err) {
console.error(`API failed for ${url}: ${err.message}`);
return null; // ← silently skips user on any failure
}
}
Steps to Reproduce
- Run
node scripts/analyze-inactivity.js
- If the LeetCode API rate-limits or returns errors for some users, those users are excluded from analysis
- No retry, no fallback — silently missing from the inactive list
Expected Behavior
Should match the resiliency pattern in sync-leaderboard.js:
- Retry failed requests up to 3 times with exponential backoff.
- Use concurrency of 20 (or configurable) instead of 50.
- When all retries fail, log a warning but still include the user with a "skip" flag rather than silently omitting them.
Suggested Fix
- Extract the retry interceptor from
sync-leaderboard.js (lines 11-55) into a shared module or duplicate it in analyze-inactivity.js.
- Reduce
CONCURRENCY_LIMIT from 50 to 20.
- On complete failure after retries, include the user with
{ status: "unreachable" } instead of dropping them.
Affected Files
scripts/analyze-inactivity.js
Description
The
analyze-inactivity.jsscript fetches LeetCode profile data for all registered users but is missing three safeguards thatsync-leaderboard.jsalready implements:Affected Code
Steps to Reproduce
node scripts/analyze-inactivity.jsExpected Behavior
Should match the resiliency pattern in
sync-leaderboard.js:Suggested Fix
sync-leaderboard.js(lines 11-55) into a shared module or duplicate it inanalyze-inactivity.js.CONCURRENCY_LIMITfrom 50 to 20.{ status: "unreachable" }instead of dropping them.Affected Files
scripts/analyze-inactivity.js