mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39: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
@@ -1,25 +0,0 @@
|
||||
import { RatingsInfo } from '../../commands/ratings';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { DATABASE_REPO } from '../database/getMidnightLeaderboard';
|
||||
import { octokit } from '../github/octokit';
|
||||
import throwError from '../node/throwError';
|
||||
|
||||
export default async function getArchivedRatingsInfo(
|
||||
season: number,
|
||||
region: Region,
|
||||
) {
|
||||
const { data } = await octokit.repos.getContent({
|
||||
...DATABASE_REPO,
|
||||
path: `${region}/ratings/${season}/info.json`,
|
||||
});
|
||||
|
||||
if (Array.isArray(data) || data.type !== 'file')
|
||||
throw throwError('Archived ratings info is malformed');
|
||||
|
||||
const content = Buffer.from(data.content, 'base64').toString();
|
||||
const jsonContent = JSON.parse(content) as RatingsInfo & {
|
||||
detail: undefined;
|
||||
};
|
||||
|
||||
return jsonContent;
|
||||
}
|
||||
Reference in new issue
Block a user