refacto: Changing display of revenues per planet by default + fixing WS for revenues

This commit is contained in:
gauvainboiche
2026-04-02 15:10:51 +02:00
parent a746662db4
commit 5ce2ae6c98
7 changed files with 417 additions and 97 deletions
+22 -1
View File
@@ -1,7 +1,7 @@
import { pool } from "./pools.js";
import { loadConfigFile, getConfig } from "../configLoader.js";
import { computeWorldSeedState } from "../worldSeed.js";
import { nextNoonUtc, resetAllUserActions } from "./usersDb.js";
import { nextNoonUtc, resetAllUserActions, getUsersByIds } from "./usersDb.js";
let lastSeedSlot = null;
@@ -455,6 +455,27 @@ export async function getActivePlayerIds(worldSeed) {
return result;
}
/**
* Returns per-team sorted lists of usernames who have been active this seed epoch.
* Uses a two-step lookup because users live in a separate database.
*/
export async function getActivePlayerNames(worldSeed) {
const playerIds = await getActivePlayerIds(worldSeed);
const allIds = [...playerIds.blue, ...playerIds.red];
const users = await getUsersByIds(allIds);
const teamOf = {};
for (const id of playerIds.blue) teamOf[id] = "blue";
for (const id of playerIds.red) teamOf[id] = "red";
const result = { blue: [], red: [] };
for (const user of users) {
const team = teamOf[user.id];
if (team) result[team].push(user.username);
}
result.blue.sort((a, b) => a.localeCompare(b));
result.red.sort((a, b) => a.localeCompare(b));
return result;
}
// ── Team action quota (daily, independent of world seed) ─────────────────────
export async function getTeamActionsRow(team) {