mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: cached archived ratings
This commit is contained in:
1 parent
862445259e
commit
970ab9004e
2 files changed
+24
-4
No files matched your search
+23
-3
@@ -1,13 +1,31 @@
|
|||||||
import { RatingsInfo } from '../../commands/ratings';
|
import { RatingsInfo } from '../../commands/ratings';
|
||||||
import { Region } from '../../constants/regions';
|
import { Region } from '../../constants/regions';
|
||||||
import { DATABASE_REPO } from '../database/getMidnightLeaderboard';
|
import { DATABASE_REPO } from '../../core/database/getMidnightLeaderboard';
|
||||||
import { octokit } from '../github/octokit';
|
import { octokit } from '../../core/github/octokit';
|
||||||
import throwError from '../node/throwError';
|
import throwError from '../../core/node/throwError';
|
||||||
|
|
||||||
|
const ARCHIVED_RATINGS_CACHE: Record<
|
||||||
|
Region,
|
||||||
|
Record<
|
||||||
|
number,
|
||||||
|
RatingsInfo & {
|
||||||
|
detail: undefined;
|
||||||
|
}
|
||||||
|
>
|
||||||
|
> = {
|
||||||
|
com: {},
|
||||||
|
eu: {},
|
||||||
|
asia: {},
|
||||||
|
};
|
||||||
|
|
||||||
export default async function getArchivedRatingsInfo(
|
export default async function getArchivedRatingsInfo(
|
||||||
season: number,
|
season: number,
|
||||||
region: Region,
|
region: Region,
|
||||||
) {
|
) {
|
||||||
|
if (ARCHIVED_RATINGS_CACHE[region][season]) {
|
||||||
|
return ARCHIVED_RATINGS_CACHE[region][season];
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await octokit.repos.getContent({
|
const { data } = await octokit.repos.getContent({
|
||||||
...DATABASE_REPO,
|
...DATABASE_REPO,
|
||||||
path: `${region}/ratings/${season}/info.json`,
|
path: `${region}/ratings/${season}/info.json`,
|
||||||
@@ -21,5 +39,7 @@ export default async function getArchivedRatingsInfo(
|
|||||||
detail: undefined;
|
detail: undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ARCHIVED_RATINGS_CACHE[region][season] = jsonContent;
|
||||||
|
|
||||||
return jsonContent;
|
return jsonContent;
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,11 @@ import {
|
|||||||
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
|
import { BlitzkriegRatingsLeaderboard } from '../../scripts/buildRatingsLeaderboard';
|
||||||
import { getAccountInfo } from '../_core/blitz/getAccountInfo';
|
import { getAccountInfo } from '../_core/blitz/getAccountInfo';
|
||||||
import { getClanAccountInfo } from '../_core/blitz/getClanAccountInfo';
|
import { getClanAccountInfo } from '../_core/blitz/getClanAccountInfo';
|
||||||
|
import getArchivedRatingsInfo from '../_core/blitzkrieg/getArchivedRatingsInfo';
|
||||||
import * as Leaderboard from '../components/Leaderboard';
|
import * as Leaderboard from '../components/Leaderboard';
|
||||||
import TitleBar from '../components/TitleBar';
|
import TitleBar from '../components/TitleBar';
|
||||||
import Wrapper from '../components/Wrapper';
|
import Wrapper from '../components/Wrapper';
|
||||||
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
import { REGION_NAMES_SHORT, Region } from '../constants/regions';
|
||||||
import getArchivedRatingsInfo from '../core/blitz/getArchivedRatingsInfo';
|
|
||||||
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
import getRatingsInfo from '../core/blitz/getRatingsInfo';
|
||||||
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
import regionToRegionSubdomain from '../core/blitz/regionToRegionSubdomain';
|
||||||
import getMidnightLeaderboard, {
|
import getMidnightLeaderboard, {
|
||||||
|
|||||||
Reference in new issue
Block a user