Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
491643b
perf(api): batch leaderboard stat lookups
ugcodrr May 12, 2026
ba946d1
perf(leaderboard): optimize leaderboard queries and handle unknown en…
ugcodrr May 28, 2026
d240d78
chore: remove .turbo folder
jacobk999 May 31, 2026
81e6f7b
chore: update dependencies and repo cleanup (#871)
jacobk999 Jun 2, 2026
9fa9449
chore(deps): update actions/cache digest to 27d5ce7 (#821)
renovate[bot] Jun 2, 2026
388bd6c
chore(deps): update actions/checkout digest to de0fac2 (#823)
renovate[bot] Jun 2, 2026
5cc14dc
chore(lint): enable stricter no unused variable rules (#873)
jacobk999 Jun 3, 2026
95d3b94
fix: use file urls for dynamic imports (#874)
jacobk999 Jun 3, 2026
7e07ac3
chore(config): migrate renovate config (#872)
renovate[bot] Jun 3, 2026
110fd10
chore: add .DS_Store to .gitignore (#833)
ugcodrr Jun 3, 2026
45f6cae
feat(copsandcrims): add shots fired stats (#829)
ugcodrr Jun 5, 2026
4021c0f
refactor(discord-bot): load duels command mode icons once (#847)
ugcodrr Jun 6, 2026
bfb1dc3
chore(deps): update actions/labeler digest to f27b608 (#880)
renovate[bot] Jun 7, 2026
81723f2
chore(deps): update pnpm/action-setup digest to b906aff (#881)
renovate[bot] Jun 7, 2026
cb6922c
feat: add bedwars dreamfest levelling and challenges (#887)
jacobk999 Jun 8, 2026
bd5104b
chore(deps): update actions/checkout digest to df4cb1c (#879)
renovate[bot] Jun 8, 2026
88ddaae
fix(rendering): ignore unsupported font glyphs (#837)
ugcodrr Jun 8, 2026
b729496
fix(skywars): add missing prestige schemes (#840)
ugcodrr Jun 8, 2026
155f898
chore(deps): update pnpm/action-setup action to v6 (#885)
renovate[bot] Jun 8, 2026
1c0b240
chore: update lockfile
jacobk999 Jun 9, 2026
9df3916
fix(discord): import event handlers from correct file path (#888)
jacobk999 Jun 9, 2026
bee79ac
chore: pin minecraft-protocol to 1.61.0
jacobk999 Jun 9, 2026
98d9f50
chore(deploy): install node modules with frozen lockfile
jacobk999 Jun 9, 2026
7947a67
chore: update lockfile
jacobk999 Jun 9, 2026
ac1cd80
fix(bedwars): use proper field for level progression
ugcodrr Jun 9, 2026
86584a5
fix(font-renderer): Add back &r (reset) formatting behavior (#891)
ugcodrr Jun 12, 2026
e9aee26
fix(i18n-loader): only load language files/folders (#897)
ugcodrr Jun 13, 2026
2bb2648
fix(discord-bot): use statsify skin API for minecraft head URLs (#865)
ugcodrr Jun 16, 2026
52fa5a2
refactor(leaderboard): improve handling of additional stats
ugcodrr Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions apps/api/src/guild/leaderboards/guild-leaderboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,30 @@ export class GuildLeaderboardService extends LeaderboardService {
return acc;
}, {} as Record<string, boolean>);

selector.id = true;
selector.nameFormatted = true;

return await Promise.all(
ids.map(async (id) => {
const guild = await this.guildModel
.findOne()
.where("id")
.equals(id)
.select(selector)
.lean()
.exec();

const additionalStats = flatten(guild) as LeaderboardAdditionalStats;
additionalStats.name = additionalStats.nameFormatted;

return additionalStats;
})
);
const uniqueIds = [...new Set(ids)];

const guilds = await this.guildModel
.find({ id: { $in: uniqueIds } })
.select(selector)
.lean()
.exec();

const guildsById = new Map(guilds.map((guild) => [guild.id, guild]));

return ids.map((id) => {
const guild = guildsById.get(id);

if (!guild) {
return { name: "Unknown" } as LeaderboardAdditionalStats;
}

const additionalStats = flatten(guild) as LeaderboardAdditionalStats;
additionalStats.name = additionalStats.nameFormatted;

return additionalStats;
});
}
}
16 changes: 9 additions & 7 deletions apps/api/src/leaderboards/leaderboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ export abstract class LeaderboardService {
LeaderboardScanner.getLeaderboardField(constructor, extraDisplay, false) :
undefined;

const additionalStats = await this.getAdditionalStats(
leaderboard.map(({ id }) => id),
[
...additionalFields.filter((k) => k !== field),
...(extraDisplay ? [extraDisplay] : []),
]
);
const additionalStats = leaderboard.length ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the getAdditionalStats function now can return invalid data, with Unknown as the name, we should probably instead just handle the case if a player or guild is missing rather than just returning garbage data.

await this.getAdditionalStats(
leaderboard.map(({ id }) => id),
[
...additionalFields.filter((k) => k !== field),
...(extraDisplay ? [extraDisplay] : []),
]
) :
[];

const data = leaderboard.map((doc, index) => {
const stats = additionalStats[index];
Expand Down
39 changes: 23 additions & 16 deletions apps/api/src/player/leaderboards/player-leaderboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,29 @@ export class PlayerLeaderboardService extends LeaderboardService {
}, {} as Record<string, boolean>);

selector.displayName = true;
selector.uuid = true;

return await Promise.all(
ids.map(async (id) => {
const player = await this.playerModel
.findOne()
.where("uuid")
.equals(id)
.select(selector)
.lean()
.exec();

const additionalStats = flatten(player) as LeaderboardAdditionalStats;
additionalStats.name = additionalStats.displayName;

return additionalStats;
})
);
const uniqueIds = [...new Set(ids)];

const players = await this.playerModel
.find({ uuid: { $in: uniqueIds } })
.select(selector)
.lean()
.exec();

const playersById = new Map(players.map((player) => [player.uuid, player]));

return ids.map((id) => {
const player = playersById.get(id);

if (!player) {
return { name: "Unknown" } as LeaderboardAdditionalStats;
}

const additionalStats = flatten(player) as LeaderboardAdditionalStats;
additionalStats.name = additionalStats.displayName;

return additionalStats;
});
}
}
Loading