Skip to content

Commit

Permalink
Fix bug in results page
Browse files Browse the repository at this point in the history
  • Loading branch information
enkoder committed Jul 15, 2024
1 parent f473df0 commit c6e48dd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
12 changes: 6 additions & 6 deletions api/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,13 @@ export const RecalculateLeaderboardSchema = {

export const UserResultsResponseComponent = z
.object({
user_name: z.string(),
user_id: z.number(),
userName: z.string(),
userId: z.number(),
rank: z.number(),
seasonId: z.number().optional(),
seasonName: z.string().optional(),
format: FormatComponent.optional(),
factionCode: z.string().optional(),
seasonId: z.number().optional().nullable(),
seasonName: z.string().optional().nullable(),
format: FormatComponent.optional().nullable(),
factionCode: z.string().optional().nullable(),
results: z.array(ResultComponent),
})
.openapi("UserResultsResponse");
Expand Down
23 changes: 13 additions & 10 deletions api/src/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ResultComponent,
type UpdateUserComponentType,
UserComponent,
UserResultsResponseComponent,
} from "../openapi.js";
import type { FactionCode, Format } from "../schema.js";
import type { Env, RequestWithDB } from "../types.d.js";
Expand Down Expand Up @@ -133,15 +134,17 @@ export class GetUserResults extends OpenAPIRoute {
}
}

return json({
user_id: user.id,
user_name: user.name,
season_id: seasonId || null,
seasonName: seasonName,
format: format,
factionCode: faction?.code || null,
rank: currentRank,
results: results.map((result) => ResultComponent.parse(result)),
});
return json(
UserResultsResponseComponent.parse({
userId: user.id,
userName: user.name,
seasonId: seasonId || null,
seasonName: seasonName,
format: format,
factionCode: faction?.code || null,
rank: currentRank,
results: results.map((result) => ResultComponent.parse(result)),
}),
);
}
}
4 changes: 2 additions & 2 deletions app/src/client/models/UserResultsResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type { Format } from './Format';
import type { Result } from './Result';

export type UserResultsResponse = {
user_name: string;
user_id: number;
userName: string;
userId: number;
rank: number;
seasonId?: number;
seasonName?: string;
Expand Down
2 changes: 1 addition & 1 deletion app/src/output.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c6e48dd

Please sign in to comment.