2023-10-31 12:35:32 -05:00
|
|
|
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
|
|
|
|
import { Region } from '../../constants/regions';
|
|
|
|
|
|
|
|
|
|
const LEADERBOARD_CACHE: Record<
|
|
|
|
|
Region,
|
|
|
|
|
Record<number, BlitzkriegRatingsLeaderboard>
|
|
|
|
|
> = {
|
|
|
|
|
asia: {},
|
|
|
|
|
eu: {},
|
|
|
|
|
com: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export async function getArchivedRatingsLeaderboard(
|
|
|
|
|
region: Region,
|
|
|
|
|
season: number,
|
|
|
|
|
) {
|
|
|
|
|
if (LEADERBOARD_CACHE[region][season]) {
|
|
|
|
|
return LEADERBOARD_CACHE[region][season];
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-07 11:36:08 -06:00
|
|
|
const response = await fetch(
|
2023-11-27 12:01:32 -06:00
|
|
|
`https://raw.githubusercontent.com/tresabhi/blitzkrieg-assets/main/${region}/ratings/${season}/latest.json`,
|
2023-11-07 11:36:08 -06:00
|
|
|
);
|
2023-10-31 12:35:32 -05:00
|
|
|
const json = (await response.json()) as BlitzkriegRatingsLeaderboard;
|
|
|
|
|
LEADERBOARD_CACHE[region][season] = json;
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
}
|