diff --git a/package.json b/package.json index 951580865..7b4afd2b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blitzkrieg", - "version": "1.3.2", + "version": "1.3.3", "description": "", "main": "index.js", "type": "module", diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index e71c5e0e0..e26255ac3 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -35,7 +35,7 @@ const periodNames: Record = { export default { inProduction: true, - inDevelopment: false, + inDevelopment: true, inPublic: true, command: new SlashCommandBuilder() diff --git a/src/components/GenericStats/index.tsx b/src/components/GenericStats/index.tsx index d404b01c9..6f55650b0 100644 --- a/src/components/GenericStats/index.tsx +++ b/src/components/GenericStats/index.tsx @@ -11,10 +11,11 @@ export default function GenericStats({ stats, columnCount = 2, }: GenericStatsProps) { - const itemsPerRow = Math.ceil(stats.length / columnCount); + const filteredStats = stats.filter(([, value]) => value !== `${-Infinity}`); + const itemsPerRow = Math.ceil(filteredStats.length / columnCount); const columns: Stat[][] = []; - stats.forEach((stat, index) => { + filteredStats.forEach((stat, index) => { const column = Math.floor(index / itemsPerRow); if (!columns[column]) columns[column] = []; columns[column].push(stat); diff --git a/src/core/blitzstars/getTankStatsOverTime.ts b/src/core/blitzstars/getTankStatsOverTime.ts index 20a5964f7..cffa7293f 100644 --- a/src/core/blitzstars/getTankStatsOverTime.ts +++ b/src/core/blitzstars/getTankStatsOverTime.ts @@ -95,25 +95,28 @@ export default async function getTankStatsOverTime( return Math.max(get(latest.all), get(previous.all)); } - tanksBeforeAndAfter[tankId] = { - battles: diff((a) => a.battles), - capture_points: diff((a) => a.capture_points), - damage_dealt: diff((a) => a.damage_dealt), - damage_received: diff((a) => a.damage_received), - dropped_capture_points: diff((a) => a.dropped_capture_points), - frags: diff((a) => a.frags), - frags8p: diff((a) => a.frags8p), - hits: diff((a) => a.hits), - losses: diff((a) => a.losses), - max_frags: max((a) => a.max_frags), - max_xp: max((a) => a.max_xp), - shots: diff((a) => a.shots), - spotted: diff((a) => a.spotted), - survived_battles: diff((a) => a.survived_battles), - win_and_survived: diff((a) => a.win_and_survived), - wins: diff((a) => a.wins), - xp: diff((a) => a.xp), - }; + // check if there was a change in battles as games in ratings do update last_battle_time + if (diff((a) => a.battles) > 0) { + tanksBeforeAndAfter[tankId] = { + battles: diff((a) => a.battles), + capture_points: diff((a) => a.capture_points), + damage_dealt: diff((a) => a.damage_dealt), + damage_received: diff((a) => a.damage_received), + dropped_capture_points: diff((a) => a.dropped_capture_points), + frags: diff((a) => a.frags), + frags8p: diff((a) => a.frags8p), + hits: diff((a) => a.hits), + losses: diff((a) => a.losses), + max_frags: max((a) => a.max_frags), + max_xp: max((a) => a.max_xp), + shots: diff((a) => a.shots), + spotted: diff((a) => a.spotted), + survived_battles: diff((a) => a.survived_battles), + win_and_survived: diff((a) => a.win_and_survived), + wins: diff((a) => a.wins), + xp: diff((a) => a.xp), + }; + } }); return tanksBeforeAndAfter; diff --git a/src/core/blitzstars/tankopedia.ts b/src/core/blitzstars/tankopedia.ts index 0c4eaee43..638cf29d0 100644 --- a/src/core/blitzstars/tankopedia.ts +++ b/src/core/blitzstars/tankopedia.ts @@ -1,3 +1,5 @@ +import isDev from '../process/isDev.js'; + export type TankType = 'heavyTank' | 'AT-SPG' | 'mediumTank' | 'lightTank'; export interface Tankopedia { @@ -54,18 +56,20 @@ export const TANK_TYPE_EMOJIS: Record = { lightTank: '🇱', }; -console.log('Encoding tank images...'); -await Promise.all( - Object.entries(tankopedia).map(async ([, tank]) => { - if (tank.images.normal) { - const response = await fetch(tank.images.normal); - const blob = await response.arrayBuffer(); - const base64 = `data:${response.headers.get( - 'content-type', - )};base64,${Buffer.from(blob).toString('base64')}`; +if (!isDev()) { + console.log('Encoding tank images...'); + await Promise.all( + Object.entries(tankopedia).map(async ([, tank]) => { + if (tank.images.normal) { + const response = await fetch(tank.images.normal); + const blob = await response.arrayBuffer(); + const base64 = `data:${response.headers.get( + 'content-type', + )};base64,${Buffer.from(blob).toString('base64')}`; - tank.images.normal = base64; - } - }), -); -console.log('Encoded tank images'); + tank.images.normal = base64; + } + }), + ); + console.log('Encoded tank images'); +}