-
Notifications
You must be signed in to change notification settings - Fork 5
LVT-40: Warn user if manually entered match info doesn't match schedule #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jackattack-4
merged 8 commits into
main
from
jackshim415/lvt-40-warn-user-if-manually-entered-match-info-doesnt-match
Jul 8, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e115e58
add endpoint to check if match exists
jackattack-4 a495056
Fix doc types
jackattack-4 2aecc00
Add nullable to doc
jackattack-4 cecbad0
add catch for invalid params
jackattack-4 92f1427
fix docs more and add 404 response
jackattack-4 fc94cb5
fix boolean coercion and documentation
jackattack-4 3759acc
Fix documentation
jackattack-4 0eb26ea
Fix documentation more
jackattack-4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import z from "zod"; | ||
| import { addTournamentMatches } from "./addTournamentMatches.js"; | ||
| import { Request, Response } from "express"; | ||
| import prismaClient from "../../prismaClient.js"; | ||
| import { MatchType } from "@prisma/client"; | ||
|
|
||
| export const checkMatchExists = async ( | ||
| req: Request, | ||
| res: Response, | ||
| ): Promise<void> => { | ||
| try { | ||
| const parsed = z | ||
| .object({ | ||
| tournamentKey: z.string(), | ||
| teamNumber: z.coerce.number().int(), | ||
| matchNumber: z.coerce.number().int(), | ||
| isElim: z | ||
| .union([z.literal("true"), z.literal("false"), z.boolean()]) | ||
| .transform((value) => value === true || value === "true"), | ||
| }) | ||
| .safeParse(req.query); | ||
|
|
||
| if (!parsed.success) { | ||
| res.status(400).send(parsed.error.flatten()); | ||
| return; | ||
| } | ||
|
|
||
| const params = parsed.data; | ||
|
|
||
| await addTournamentMatches(params.tournamentKey); | ||
|
|
||
| const match = await prismaClient.teamMatchData.findFirst({ | ||
| where: { | ||
| matchNumber: params.matchNumber, | ||
| tournamentKey: params.tournamentKey, | ||
| teamNumber: params.teamNumber, | ||
| matchType: params.isElim | ||
| ? MatchType.ELIMINATION | ||
| : MatchType.QUALIFICATION, | ||
| }, | ||
| }); | ||
|
|
||
| if (match !== null) { | ||
| res.status(200).send({ | ||
| match, | ||
| alliance: Number(match.key.at(-1)) < 3 ? "red" : "blue", | ||
| }); | ||
| return; | ||
| } | ||
| res.status(404).send("MATCH_NOT_FOUND"); | ||
| } catch (error) { | ||
| console.log(error); | ||
| res.status(500).send(error); | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.