mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: start migration to proto for popular tanks
This commit is contained in:
1 parent
001709c25c
commit
ccb86ae824
8 files changed
+68
-66
No files matched your search
@@ -11,10 +11,10 @@ import { merge } from "lodash-es";
|
||||
import { parse } from "yaml";
|
||||
import type { Avatar } from "../../protos/avatar";
|
||||
import type { Background } from "../../protos/background";
|
||||
import type { PopularTanks } from "../../protos/popular_tanks";
|
||||
import type { Tank } from "../../protos/tank";
|
||||
import type { TankListEntry } from "../../protos/tank_list";
|
||||
import type { Tanks } from "../../protos/tanks";
|
||||
import type { PopularTanks } from "../../types/popularTanks";
|
||||
import { AbstractAPI } from "./abstract";
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
@@ -302,9 +302,17 @@ export class ServerAPI extends AbstractAPI {
|
||||
}
|
||||
}
|
||||
|
||||
const popularTanks: PopularTanks = Object.entries(views)
|
||||
.sort(([, a], [, b]) => b - a)
|
||||
.map(([id, views]) => ({ id, views }));
|
||||
for (const id in tanks) {
|
||||
if (!(id in views)) {
|
||||
views[id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const popularTanks = {
|
||||
tanks: Object.entries(views)
|
||||
.sort(([, a], [, b]) => b - a)
|
||||
.map(([id, views]) => ({ id, views })),
|
||||
} satisfies PopularTanks;
|
||||
|
||||
await mkdir("../../temp", { recursive: true });
|
||||
await writeFile("../../temp/popular.json", JSON.stringify(popularTanks));
|
||||
|
||||
Reference in new issue
Block a user