mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: added ratings neighbours
This commit is contained in:
1 parent
f7eadb08a9
commit
9e4094f3a9
5 files changed
+234
-120
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { BlitzkriegRatingsLeaderboard } from '../../../scripts/buildRatingsLeaderboard';
|
||||
import { octokit } from '../../bot';
|
||||
import { Region } from '../../constants/regions';
|
||||
|
||||
export const DATABASE_REPO = { owner: 'tresabhi', repo: 'blitzkrieg-db' };
|
||||
|
||||
export default async function getMidnightLeaderboard(
|
||||
region: Region,
|
||||
season: number,
|
||||
) {
|
||||
try {
|
||||
const { data } = await octokit.repos.getContent({
|
||||
...DATABASE_REPO,
|
||||
path: `${region}/ratings/${season}/midnight.json`,
|
||||
});
|
||||
|
||||
if (!Array.isArray(data) && data.type === 'file') {
|
||||
const content = Buffer.from(data.content, 'base64').toString();
|
||||
const jsonContent = JSON.parse(content) as BlitzkriegRatingsLeaderboard;
|
||||
|
||||
return jsonContent;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('No midnight leaderboard found');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user