diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-12 01:54:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-12 01:54:36 +0900 |
| commit | ab6abc3a7619be89dda1bc3ab0b3f19ff69b575f (patch) | |
| tree | 57f4b6da4682ec43cbd7ba2a51c5866f226b0035 /frontend | |
| parent | b97b245861b93a5ab5f8bde095d9920fabd0cbbd (diff) | |
| download | iosdc-japan-2024-albatross-ab6abc3a7619be89dda1bc3ab0b3f19ff69b575f.tar.gz iosdc-japan-2024-albatross-ab6abc3a7619be89dda1bc3ab0b3f19ff69b575f.tar.zst iosdc-japan-2024-albatross-ab6abc3a7619be89dda1bc3ab0b3f19ff69b575f.zip | |
refactor(frontend): rename SubmissionResult and VerificationResult for consistant naming
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/app/components/ExecStatusIndicatorIcon.tsx | 4 | ||||
| -rw-r--r-- | frontend/app/components/GolfWatchApp.client.tsx | 51 | ||||
| -rw-r--r-- | frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx | 62 | ||||
| -rw-r--r-- | frontend/app/models/ExecResult.ts (renamed from frontend/app/models/VerificationResult.ts) | 6 | ||||
| -rw-r--r-- | frontend/app/models/PlayerInfo.ts | 4 | ||||
| -rw-r--r-- | frontend/app/models/SubmitResult.ts (renamed from frontend/app/models/SubmissionResult.ts) | 14 |
6 files changed, 67 insertions, 74 deletions
diff --git a/frontend/app/components/ExecStatusIndicatorIcon.tsx b/frontend/app/components/ExecStatusIndicatorIcon.tsx index c5b37f8..b5c53ec 100644 --- a/frontend/app/components/ExecStatusIndicatorIcon.tsx +++ b/frontend/app/components/ExecStatusIndicatorIcon.tsx @@ -5,10 +5,10 @@ import { faRotate, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { VerificationResultStatus } from "../models/VerificationResult"; +import { ExecResultStatus } from "../models/ExecResult"; type Props = { - status: VerificationResultStatus; + status: ExecResultStatus; }; export default function ExecStatusIndicatorIcon({ status }: Props) { diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx index 3f97d2a..7041572 100644 --- a/frontend/app/components/GolfWatchApp.client.tsx +++ b/frontend/app/components/GolfWatchApp.client.tsx @@ -78,14 +78,14 @@ export default function GolfWatchApp({ iconPath: playerA?.icon_path ?? null, score: null, code: "", - submissionResult: undefined, + submitResult: undefined, }); const [playerInfoB, setPlayerInfoB] = useState<PlayerInfo>({ displayName: playerB?.display_name ?? null, iconPath: playerB?.icon_path ?? null, score: null, code: "", - submissionResult: undefined, + submitResult: undefined, }); if (readyState === ReadyState.UNINSTANTIATED) { @@ -125,12 +125,12 @@ export default function GolfWatchApp({ player_id === playerA?.user_id ? setPlayerInfoA : setPlayerInfoB; setter((prev) => ({ ...prev, - submissionResult: { + submitResult: { status: "running", - verificationResults: game.verification_steps.map((v) => ({ - testcase_id: v.testcase_id, + execResults: game.verification_steps.map((r) => ({ + testcase_id: r.testcase_id, status: "running", - label: v.label, + label: r.label, stdout: "", stderr: "", })), @@ -143,21 +143,20 @@ export default function GolfWatchApp({ player_id === playerA?.user_id ? setPlayerInfoA : setPlayerInfoB; setter((prev) => { const ret = { ...prev }; - if (ret.submissionResult === undefined) { + if (ret.submitResult === undefined) { return ret; } - ret.submissionResult = { - ...ret.submissionResult, - verificationResults: ret.submissionResult.verificationResults.map( - (v) => - v.testcase_id === testcase_id && v.status === "running" - ? { - ...v, - status, - stdout, - stderr, - } - : v, + ret.submitResult = { + ...ret.submitResult, + execResults: ret.submitResult.execResults.map((r) => + r.testcase_id === testcase_id && r.status === "running" + ? { + ...r, + status, + stdout, + stderr, + } + : r, ), }; return ret; @@ -168,11 +167,11 @@ export default function GolfWatchApp({ player_id === playerA?.user_id ? setPlayerInfoA : setPlayerInfoB; setter((prev) => { const ret = { ...prev }; - if (ret.submissionResult === undefined) { + if (ret.submitResult === undefined) { return ret; } - ret.submissionResult = { - ...ret.submissionResult, + ret.submitResult = { + ...ret.submitResult, status, }; if (status === "success") { @@ -182,10 +181,10 @@ export default function GolfWatchApp({ } } } else { - ret.submissionResult.verificationResults = - ret.submissionResult.verificationResults.map((v) => - v.status === "running" ? { ...v, status: "canceled" } : v, - ); + ret.submitResult.execResults = ret.submitResult.execResults.map( + (r) => + r.status === "running" ? { ...r, status: "canceled" } : r, + ); } return ret; }); diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx index 5ca778b..bdd1ac3 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -1,5 +1,5 @@ import { PlayerInfo } from "../../models/PlayerInfo"; -import { submissionResultStatusToLabel } from "../../models/SubmissionResult"; +import { submitResultStatusToLabel } from "../../models/SubmitResult"; import ExecStatusIndicatorIcon from "../ExecStatusIndicatorIcon"; type Props = { @@ -60,28 +60,26 @@ export default function GolfWatchAppGaming({ </div> <div> <div> - {submissionResultStatusToLabel( - playerInfoA.submissionResult?.status ?? null, + {submitResultStatusToLabel( + playerInfoA.submitResult?.status ?? null, )} </div> <div> <ol> - {playerInfoA.submissionResult?.verificationResults.map( - (result) => ( - <li key={result.testcase_id ?? -1}> + {playerInfoA.submitResult?.execResults.map((result) => ( + <li key={result.testcase_id ?? -1}> + <div> <div> - <div> - <ExecStatusIndicatorIcon status={result.status} />{" "} - {result.label} - </div> - <div> - {result.stdout} - {result.stderr} - </div> + <ExecStatusIndicatorIcon status={result.status} />{" "} + {result.label} </div> - </li> - ), - )} + <div> + {result.stdout} + {result.stderr} + </div> + </div> + </li> + ))} </ol> </div> </div> @@ -92,28 +90,26 @@ export default function GolfWatchAppGaming({ </div> <div> <div> - {submissionResultStatusToLabel( - playerInfoB.submissionResult?.status ?? null, + {submitResultStatusToLabel( + playerInfoB.submitResult?.status ?? null, )} </div> <div> <ol> - {playerInfoB.submissionResult?.verificationResults.map( - (result, idx) => ( - <li key={idx}> + {playerInfoB.submitResult?.execResults.map((result, idx) => ( + <li key={idx}> + <div> + <div> + <ExecStatusIndicatorIcon status={result.status} />{" "} + {result.label} + </div> <div> - <div> - <ExecStatusIndicatorIcon status={result.status} />{" "} - {result.label} - </div> - <div> - {result.stdout} - {result.stderr} - </div> + {result.stdout} + {result.stderr} </div> - </li> - ), - )} + </div> + </li> + ))} </ol> </div> </div> diff --git a/frontend/app/models/VerificationResult.ts b/frontend/app/models/ExecResult.ts index 09a7ef4..59b8ee8 100644 --- a/frontend/app/models/VerificationResult.ts +++ b/frontend/app/models/ExecResult.ts @@ -1,4 +1,4 @@ -export type VerificationResultStatus = +export type ExecResultStatus = | "running" | "success" | "wrong_answer" @@ -8,9 +8,9 @@ export type VerificationResultStatus = | "internal_error" | "canceled"; -export type VerificationResult = { +export type ExecResult = { testcase_id: number | null; - status: VerificationResultStatus; + status: ExecResultStatus; label: string; stdout: string; stderr: string; diff --git a/frontend/app/models/PlayerInfo.ts b/frontend/app/models/PlayerInfo.ts index 7206a8b..30cccea 100644 --- a/frontend/app/models/PlayerInfo.ts +++ b/frontend/app/models/PlayerInfo.ts @@ -1,9 +1,9 @@ -import type { SubmissionResult } from "./SubmissionResult"; +import type { SubmitResult } from "./SubmitResult"; export type PlayerInfo = { displayName: string | null; iconPath: string | null; score: number | null; code: string | null; - submissionResult?: SubmissionResult; + submitResult?: SubmitResult; }; diff --git a/frontend/app/models/SubmissionResult.ts b/frontend/app/models/SubmitResult.ts index 7311494..403a0db 100644 --- a/frontend/app/models/SubmissionResult.ts +++ b/frontend/app/models/SubmitResult.ts @@ -1,6 +1,6 @@ -import type { VerificationResult } from "./VerificationResult"; +import type { ExecResult } from "./ExecResult"; -export type SubmissionResultStatus = +export type SubmitResultStatus = | "running" | "success" | "wrong_answer" @@ -9,14 +9,12 @@ export type SubmissionResultStatus = | "runtime_error" | "internal_error"; -export type SubmissionResult = { - status: SubmissionResultStatus; - verificationResults: VerificationResult[]; +export type SubmitResult = { + status: SubmitResultStatus; + execResults: ExecResult[]; }; -export function submissionResultStatusToLabel( - status: SubmissionResultStatus | null, -) { +export function submitResultStatusToLabel(status: SubmitResultStatus | null) { switch (status) { case null: return "-"; |
