mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: tankopedia normalized data caching
This commit is contained in:
1 parent
affe089565
commit
4e49d22c4c
4 files changed
+129
-8
No files matched your search
@@ -40,7 +40,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -19,6 +19,9 @@ export interface Tankopedia {
|
||||
}
|
||||
|
||||
export const tankopedia: Tankopedia = {};
|
||||
export const TANK_IDS: number[] = [];
|
||||
export const TANKS: TankopediaEntry[] = [];
|
||||
export const TANK_NAMES: string[] = [];
|
||||
|
||||
console.log('Caching tankopedia...');
|
||||
fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
@@ -30,7 +33,14 @@ fetch('https://www.blitzstars.com/bs-tankopedia.json')
|
||||
)
|
||||
.then((wargamingResponse) => {
|
||||
Object.assign(tankopedia, wargamingResponse.data);
|
||||
console.log('Cached tankopedia');
|
||||
Object.entries(tankopedia).forEach(([idString, entry]) => {
|
||||
const id = Number(idString);
|
||||
|
||||
TANK_IDS.push(id);
|
||||
TANKS.push(entry);
|
||||
TANK_NAMES.push(entry.name);
|
||||
}),
|
||||
console.log('Cached tankopedia');
|
||||
});
|
||||
|
||||
export const TANK_ICONS: Record<TankType, string> = {
|
||||
@@ -52,7 +62,3 @@ export const TIER_ROMAN_NUMERALS: Record<number, string> = {
|
||||
9: 'IX',
|
||||
10: 'X',
|
||||
};
|
||||
|
||||
export const TANK_IDS = Object.keys(tankopedia).map((id) => Number(id));
|
||||
export const TANKS = TANK_IDS.map((id) => tankopedia[id]);
|
||||
export const TANK_NAMES = TANKS.map((tank) => tank.name);
|
||||
Reference in new issue
Block a user