feat: implement real-time leaderboard system with XP and voice channel tracking features

This commit is contained in:
2026-07-25 21:26:53 +07:00 Unverified
parent bb6740fcee
commit 3f4b670170
18 changed files with 531 additions and 178 deletions
+27
View File
@@ -81,6 +81,19 @@ describe("XP leaderboard", () => {
expect(result.rows.map((row) => row.userId)).toEqual(["1", "2", "3"]);
});
test("searches identities while preserving overall ranks", () => {
const result = buildXpLeaderboard([
xpRow("top", "1000", 4, "Alpha"),
xpRow("target", "900", 3, "Beta"),
xpRow("third", "800", 2, "Gamma"),
], 1, "target-user");
expect(result.totalRows).toBe(1);
expect(result.rows.map(({ userId, rank }) => [userId, rank])).toEqual([
["target", 2],
]);
});
});
describe("voice leaderboard", () => {
@@ -131,6 +144,20 @@ describe("voice leaderboard", () => {
expect(unresolved?.username).toBeNull();
expect(shortenDiscordId("123456789012345678")).toBe("12345…5678");
});
test("searches aggregated voice rows", () => {
const result = buildVoiceLeaderboard(
rows,
["voice-1", "voice-2"],
1,
undefined,
"missing",
);
expect(result.rows.map(({ userId, rank }) => [userId, rank])).toEqual([
["missing", 3],
]);
});
});
describe("leaderboard formatting", () => {