Add player bug reports and profile identity features
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user