Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions packages/backend/src/graphql/resolvers/playlists/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export const playlistQueries = {
layoutId: number;
sizeId: number;
setIds: string;
angle: number;
page?: number;
pageSize?: number;
} },
Expand Down Expand Up @@ -364,9 +365,8 @@ export const playlistQueries = {
tables.climbStats,
and(
eq(tables.climbStats.climbUuid, dbSchema.playlistClimbs.climbUuid),
// Only join stats when we have a specific angle to match
// Use playlist angle if set, otherwise use climb's default angle
eq(tables.climbStats.angle, sql`COALESCE(${dbSchema.playlistClimbs.angle}, ${tables.climbs.angle})`)
// Use the route angle (from input) to fetch stats for the current board angle
eq(tables.climbStats.angle, input.angle)
)
)
.leftJoin(
Expand All @@ -383,14 +383,15 @@ export const playlistQueries = {
const trimmedResults = hasMore ? results.slice(0, pageSize) : results;

// Transform results to Climb type
// Use the input angle (route angle) for consistent stats display
const climbs: Climb[] = trimmedResults.map((result) => ({
uuid: result.uuid || result.climbUuid,
layoutId: result.layoutId,
setter_username: result.setter_username || '',
name: result.name || '',
description: result.description || '',
frames: result.frames || '',
angle: result.angle ?? 0,
angle: input.angle,
ascensionist_count: Number(result.ascensionist_count || 0),
difficulty: result.difficulty || '',
quality_average: result.quality_average?.toString() || '0',
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/validation/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export const GetPlaylistClimbsInputSchema = z.object({
layoutId: z.number().int().positive(),
sizeId: z.number().int().positive(),
setIds: z.string().min(1),
angle: z.number().int(),
page: z.number().int().min(0).optional(),
pageSize: z.number().int().min(1).max(100).optional(),
});
1 change: 1 addition & 0 deletions packages/shared-schema/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export const typeDefs = /* GraphQL */ `
layoutId: Int!
sizeId: Int!
setIds: String!
angle: Int!
page: Int
pageSize: Int
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function PlaylistClimbsList({
layoutId: boardDetails.layout_id,
sizeId: boardDetails.size_id,
setIds: boardDetails.set_ids.join(','),
angle: angle,
page: pageParam,
pageSize: 20,
},
Expand Down
1 change: 1 addition & 0 deletions packages/web/app/lib/graphql/operations/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export interface GetPlaylistClimbsInput {
layoutId: number;
sizeId: number;
setIds: string;
angle: number;
page?: number;
pageSize?: number;
}
Expand Down
Loading