feat: tracking

This commit is contained in:
TrèsAbhi committed 2025-10-14 21:36:37 -05:00
1 parent 263f292a59
commit ea048da7a2
11 files changed
+272 -106

No files matched your search

@@ -28,12 +28,17 @@ export async function generatePlaylist() {
fisherYates(filtered);
Playlist.mutate((draft) => {
draft.list = filtered.map((tank) => ({
tank,
battles: stats[tank.id]?.all.battles,
wins: stats[tank.id]?.all.wins,
last: stats[tank.id]?.last_battle_time,
checked: false,
}));
draft.list = filtered.map((tank) => {
const tankStats = stats[tank.id];
const then = tankStats
? {
battles: tankStats.all.battles,
wins: tankStats.all.wins,
last: tankStats.last_battle_time,
}
: undefined;
return { id: tank.id, then, now: then };
});
});
}
@@ -0,0 +1,32 @@
import {
getTankStats,
idToRegion,
type IndividualTankStats,
} from "@blitzkit/core";
import { App } from "../../stores/app";
import { Playlist } from "../../stores/playlist";
export async function updatePlaylist() {
const id = App.state.logins.wargaming?.id;
const statsList = id ? await getTankStats(idToRegion(id), id) : undefined;
const stats: Record<number, IndividualTankStats> = {};
if (statsList) {
for (const tankStat of statsList) {
stats[tankStat.tank_id] = tankStat;
}
}
Playlist.mutate((draft) => {
draft.list?.map((item) => {
const tankStats = stats[item.id];
item.now = tankStats
? {
battles: tankStats.all.battles,
wins: tankStats.all.wins,
last: tankStats.last_battle_time,
}
: undefined;
});
});
}