Add player bug reports and profile identity features

This commit is contained in:
2026-10-08 18:27:20 +05:00
parent 36e8d11eb4
commit 0b08672f4a
51 changed files with 3938 additions and 45 deletions

View File

@@ -17,7 +17,7 @@ export async function leaderboard({
limit?: number;
} = {}): Promise<LeaderboardData | null> {
try {
return required(
const data = required(
await admin().rpc("player_leaderboard", {
p_difficulty: difficulty,
p_search: search,
@@ -25,6 +25,30 @@ export async function leaderboard({
p_limit: limit,
}),
) as unknown as LeaderboardData;
const ids = [
...new Set(
[...data.entries, ...data.leaders].map((entry) => entry.player_id),
),
];
const profiles = ids.length
? required(
await admin()
.from("profiles")
.select(
"id,name_glow,glow_color,role,bug_finder,custom_prefix,custom_prefix_icon",
)
.in("id", ids),
)
: [];
const addGlow = (entry: LeaderboardData["entries"][number]) => ({
...entry,
...profiles.find((profile) => profile.id === entry.player_id),
});
return {
...data,
entries: data.entries.map(addGlow),
leaders: data.leaders.map(addGlow),
};
} catch (error) {
// A leaderboard outage must not take the map catalog or homepage offline.
console.error(