style: apply prettier formatting to all files
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,55 +6,61 @@ import { getGraphQLClient } from "$lib/api";
|
||||
const LEADERBOARD_QUERY = gql`
|
||||
query Leaderboard($limit: Int, $offset: Int) {
|
||||
leaderboard(limit: $limit, offset: $offset) {
|
||||
user_id display_name avatar
|
||||
total_weighted_points total_raw_points
|
||||
recordings_count playbacks_count achievements_count rank
|
||||
user_id
|
||||
display_name
|
||||
avatar
|
||||
total_weighted_points
|
||||
total_raw_points
|
||||
recordings_count
|
||||
playbacks_count
|
||||
achievements_count
|
||||
rank
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const load: PageServerLoad = async ({ fetch, url, locals }) => {
|
||||
// Guard: Redirect to login if not authenticated
|
||||
if (!locals.authStatus.authenticated) {
|
||||
throw redirect(302, "/login");
|
||||
}
|
||||
// Guard: Redirect to login if not authenticated
|
||||
if (!locals.authStatus.authenticated) {
|
||||
throw redirect(302, "/login");
|
||||
}
|
||||
|
||||
try {
|
||||
const limit = parseInt(url.searchParams.get("limit") || "100");
|
||||
const offset = parseInt(url.searchParams.get("offset") || "0");
|
||||
try {
|
||||
const limit = parseInt(url.searchParams.get("limit") || "100");
|
||||
const offset = parseInt(url.searchParams.get("offset") || "0");
|
||||
|
||||
const client = getGraphQLClient(fetch);
|
||||
const data = await client.request<{
|
||||
leaderboard: {
|
||||
user_id: string;
|
||||
display_name: string | null;
|
||||
avatar: string | null;
|
||||
total_weighted_points: number | null;
|
||||
total_raw_points: number | null;
|
||||
recordings_count: number | null;
|
||||
playbacks_count: number | null;
|
||||
achievements_count: number | null;
|
||||
rank: number;
|
||||
}[];
|
||||
}>(LEADERBOARD_QUERY, { limit, offset });
|
||||
const client = getGraphQLClient(fetch);
|
||||
const data = await client.request<{
|
||||
leaderboard: {
|
||||
user_id: string;
|
||||
display_name: string | null;
|
||||
avatar: string | null;
|
||||
total_weighted_points: number | null;
|
||||
total_raw_points: number | null;
|
||||
recordings_count: number | null;
|
||||
playbacks_count: number | null;
|
||||
achievements_count: number | null;
|
||||
rank: number;
|
||||
}[];
|
||||
}>(LEADERBOARD_QUERY, { limit, offset });
|
||||
|
||||
return {
|
||||
leaderboard: data.leaderboard || [],
|
||||
pagination: {
|
||||
limit,
|
||||
offset,
|
||||
hasMore: data.leaderboard?.length === limit,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Leaderboard load error:", error);
|
||||
return {
|
||||
leaderboard: [],
|
||||
pagination: {
|
||||
limit: 100,
|
||||
offset: 0,
|
||||
hasMore: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
leaderboard: data.leaderboard || [],
|
||||
pagination: {
|
||||
limit,
|
||||
offset,
|
||||
hasMore: data.leaderboard?.length === limit,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Leaderboard load error:", error);
|
||||
return {
|
||||
leaderboard: [],
|
||||
pagination: {
|
||||
limit: 100,
|
||||
offset: 0,
|
||||
hasMore: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user