Private
Public Access
1
0

refacto: Displaying number of players for each team + adding logo at registration

This commit is contained in:
gauvainboiche
2026-03-31 16:35:08 +02:00
parent fa4fec3a11
commit d1240adbb7
10 changed files with 154 additions and 15 deletions

View File

@@ -273,3 +273,17 @@ export async function getScores(worldSeed) {
);
return rows;
}
// ── Active player counts (players who have played in the current epoch) ───────
export async function getActivePlayerCounts(worldSeed) {
const { rows } = await pool.query(
`SELECT team, COUNT(DISTINCT user_id)::int AS count
FROM user_cooldowns WHERE world_seed = $1
GROUP BY team`,
[worldSeed]
);
const result = { blue: 0, red: 0 };
for (const row of rows) result[row.team] = row.count;
return result;
}

View File

@@ -42,4 +42,13 @@ export async function getUserById(id) {
[id]
);
return rows[0] ?? null;
}
export async function getTeamPlayerCounts() {
const { rows } = await usersPool.query(
`SELECT team, COUNT(*)::int AS count FROM users GROUP BY team`
);
const result = { blue: 0, red: 0 };
for (const row of rows) result[row.team] = row.count;
return result;
}