mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: no double fetch and caching
This commit is contained in:
1 parent
6600bba58c
commit
fbde9ec64f
4 files changed
+243
-120
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
RatingsNeighbors,
|
||||
RatingsPlayer,
|
||||
} from '../src/commands/ratings';
|
||||
import { patientFetch } from '../src/core/blitzkrieg/patientFetch';
|
||||
import commitMultipleFiles from './commitMultipleFiles.js';
|
||||
|
||||
/*
|
||||
@@ -18,22 +19,8 @@ import commitMultipleFiles from './commitMultipleFiles.js';
|
||||
* [region]/ratings/[season]/midnight.json: last midnight's leaderboard relative to the region
|
||||
*/
|
||||
|
||||
async function patientFetch(url: string) {
|
||||
let patientResponse: Response;
|
||||
|
||||
while (patientResponse! === undefined) {
|
||||
try {
|
||||
patientResponse = await fetch(url);
|
||||
} catch (error) {
|
||||
console.warn(`Failed to fetch ${url}; retrying in 1 minute...`);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1 * 60 * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
return patientResponse;
|
||||
}
|
||||
|
||||
export type BlitzkriegRatingsLeaderboard = { id: number; score: number }[];
|
||||
export type BlitzkriegRatingsLeaderboardEntry = { id: number; score: number };
|
||||
export type BlitzkriegRatingsLeaderboard = BlitzkriegRatingsLeaderboardEntry[];
|
||||
|
||||
const publish = argv.includes('--publish');
|
||||
const latest = argv.includes('--latest');
|
||||
|
||||
Reference in new issue
Block a user