From 9c2f380bde2382ad77d34a3ff65893904f82cf3e Mon Sep 17 00:00:00 2001 From: kiharu3112 Date: Sat, 6 Jan 2024 03:19:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:Right,Left=E3=82=92right,left=E3=81=AB?= =?UTF-8?q?=E7=BD=AE=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/match/adaptor/json.ts | 12 ++++----- src/match/controller.ts | 8 +++--- src/match/match.test.ts | 8 +++--- src/match/match.ts | 10 ++++---- src/match/service/edit.test.ts | 12 ++++----- src/match/service/generate.test.ts | 40 +++++++++++++++--------------- src/match/service/generate.ts | 14 +++++------ src/match/service/get.test.ts | 10 ++++---- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/match/adaptor/json.ts b/src/match/adaptor/json.ts index 8bc5e87..7daf606 100644 --- a/src/match/adaptor/json.ts +++ b/src/match/adaptor/json.ts @@ -17,8 +17,8 @@ interface matchResultJSON { } interface matchResultPairJSON { - Left: matchResultJSON; - Right: matchResultJSON; + left: matchResultJSON; + right: matchResultJSON; } interface matchResultFinalPairJSON { @@ -31,8 +31,8 @@ interface MatchJSON { matchType: string; courseIndex: number; teams: { - Left: EntryJSON | undefined; - Right: EntryJSON | undefined; + left: EntryJSON | undefined; + right: EntryJSON | undefined; }; results?: matchResultPairJSON | matchResultFinalPairJSON; } @@ -119,8 +119,8 @@ export class JSONMatchRepository implements MatchRepository { return { id: match.id, teams: { - Left: covertToEntryJSON(match.teams.Left), - Right: covertToEntryJSON(match.teams.Right), + left: covertToEntryJSON(match.teams.left), + right: covertToEntryJSON(match.teams.right), }, matchType: match.matchType, courseIndex: match.courseIndex, diff --git a/src/match/controller.ts b/src/match/controller.ts index c49e6cc..28f484c 100644 --- a/src/match/controller.ts +++ b/src/match/controller.ts @@ -103,8 +103,8 @@ export class MatchController { return { id: i.id, teams: { - left: toTeamJSON(i.teams.Left), - right: toTeamJSON(i.teams.Right), + left: toTeamJSON(i.teams.left), + right: toTeamJSON(i.teams.right), }, matchType: i.matchType, courseIndex: i.courseIndex, @@ -120,8 +120,8 @@ interface matchResultJSON { } interface matchResultPairJSON { - Left: matchResultJSON; - Right: matchResultJSON; + left: matchResultJSON; + right: matchResultJSON; } interface matchResultFinalPairJSON { diff --git a/src/match/match.test.ts b/src/match/match.test.ts index 7183e24..57252f5 100644 --- a/src/match/match.test.ts +++ b/src/match/match.test.ts @@ -22,13 +22,13 @@ describe("正しくインスタンスを生成できる", () => { it("試合相手が居るとき", () => { const actual = Match.new({ id: "999", - teams: { Left: entry1, Right: entry2 }, + teams: { left: entry1, right: entry2 }, matchType: "primary", courseIndex: 0, }); expect(actual.id).toBe("999"); - expect(actual.teams).toEqual({ Left: entry1, Right: entry2 }); + expect(actual.teams).toEqual({ left: entry1, right: entry2 }); expect(actual.results).toBeUndefined(); expect(actual.matchType).toBe("primary"); expect(actual.courseIndex).toBe(0); @@ -38,13 +38,13 @@ describe("正しくインスタンスを生成できる", () => { it("試合相手が居ないとき", () => { const actual = Match.new({ id: "999", - teams: { Left: entry1, Right: undefined }, + teams: { left: entry1, right: undefined }, matchType: "primary", courseIndex: 0, }); expect(actual.id).toBe("999"); - expect(actual.teams).toEqual({ Left: entry1, Right: undefined }); + expect(actual.teams).toEqual({ left: entry1, right: undefined }); expect(actual.results).toBeUndefined(); expect(actual.matchType).toBe("primary"); expect(actual.courseIndex).toBe(0); diff --git a/src/match/match.ts b/src/match/match.ts index 54b1af3..8974136 100644 --- a/src/match/match.ts +++ b/src/match/match.ts @@ -34,8 +34,8 @@ import { Entry } from "../entry/entry.js"; */ // 対戦するチームのペア L左/R右 export type MatchTeams = { - Left: Entry | undefined; - Right: Entry | undefined; + left: Entry | undefined; + right: Entry | undefined; }; // 試合の結果(1チーム,1回のみ) export type MatchResult = { @@ -48,8 +48,8 @@ export type MatchResult = { }; // 予選の結果 export type MatchResultPair = { - Left: MatchResult; - Right: MatchResult; + left: MatchResult; + right: MatchResult; }; // 本選の結果 export type MatchResultFinalPair = { @@ -60,7 +60,7 @@ export type MatchResultFinalPair = { export const isMatchResultPair = ( arg: MatchResultPair | MatchResultFinalPair | undefined, ): arg is MatchResultPair => { - return (arg as MatchResultPair).Left !== undefined; + return (arg as MatchResultPair).left !== undefined; }; export interface CreateMatchArgs { diff --git a/src/match/service/edit.test.ts b/src/match/service/edit.test.ts index ee10080..ee87ea4 100644 --- a/src/match/service/edit.test.ts +++ b/src/match/service/edit.test.ts @@ -11,14 +11,14 @@ describe("EditMatch", () => { Match.reconstruct({ id: "123", teams: { - Left: Entry.new({ + left: Entry.new({ id: "101", teamName: "BBC", members: ["test1", "test2"], isMultiWalk: false, category: "Elementary", }), - Right: Entry.new({ + right: Entry.new({ id: "100", teamName: "ABC", members: ["test1"], @@ -35,12 +35,12 @@ describe("EditMatch", () => { it("正しく更新できる", async () => { const res = await editService.handle("123", { results: { - Left: { + left: { teamID: "101", points: 2, time: 100, }, - Right: { + right: { teamID: "100", points: 3, time: 200, @@ -51,12 +51,12 @@ describe("EditMatch", () => { expect(Result.isErr(res)).toBe(false); if (Result.isErr(res)) return; expect(res[1].results).toStrictEqual({ - Left: { + left: { teamID: "101", points: 2, time: 100, }, - Right: { + right: { teamID: "100", points: 3, time: 200, diff --git a/src/match/service/generate.test.ts b/src/match/service/generate.test.ts index 033f69e..924a899 100644 --- a/src/match/service/generate.test.ts +++ b/src/match/service/generate.test.ts @@ -36,11 +36,11 @@ describe("予選の対戦表を正しく生成できる", async () => { expect(Result.isErr(res)).toStrictEqual(false); for (const v of Result.unwrap(res)) { for (const j of v) { - expect(j.teams.Left!.id).not.toBe(j.teams.Right!.id); - expect(j.teams.Left!.category).toStrictEqual(j.teams.Right!.category); + expect(j.teams.left!.id).not.toBe(j.teams.right!.id); + expect(j.teams.left!.category).toStrictEqual(j.teams.right!.category); console.log( - parseInt(j.teams.Left!.id) - 8, - parseInt(j.teams.Right!.id) - 8, + parseInt(j.teams.left!.id) - 8, + parseInt(j.teams.right!.id) - 8, ); } console.log("----------------------------------"); @@ -62,28 +62,28 @@ describe("本選の対戦表を正しく生成できる", async () => { match[1].map((v) => { v.map((j) => { j.results = { - Left: { - teamID: j.teams.Left?.id ?? "", - points: Number(j.teams.Left?.id ?? 0), - time: Number(j.teams.Left?.id ?? 0), + left: { + teamID: j.teams.left?.id ?? "", + points: Number(j.teams.left?.id ?? 0), + time: Number(j.teams.left?.id ?? 0), }, - Right: { - teamID: j.teams.Right?.id ?? "", - points: Number(j.teams.Right?.id ?? 0), - time: Number(j.teams.Right?.id ?? 0), + right: { + teamID: j.teams.right?.id ?? "", + points: Number(j.teams.right?.id ?? 0), + time: Number(j.teams.right?.id ?? 0), }, }; // fixme: 消す(最下位とその1つ上の点数を同じにしている) - if (j.teams.Left) { - if (j.teams.Left.id === "1") { - j.results.Left.points = 0; - j.results.Left.time = 0; + if (j.teams.left) { + if (j.teams.left.id === "1") { + j.results.left.points = 0; + j.results.left.time = 0; } } - if (j.teams.Right) { - if (j.teams.Right.id === "1") { - j.results.Right.points = 0; - j.results.Right.time = 1; + if (j.teams.right) { + if (j.teams.right.id === "1") { + j.results.right.points = 0; + j.results.right.time = 1; } } matchRepository.update(j); diff --git a/src/match/service/generate.ts b/src/match/service/generate.ts index 82b779c..faa5e2e 100644 --- a/src/match/service/generate.ts +++ b/src/match/service/generate.ts @@ -74,7 +74,7 @@ export class GenerateMatchService { const match = Match.new({ id: crypto.randomUUID(), matchType: "primary", - teams: { Left: courses[i][k], Right: courses[i][opponentIndex] }, + teams: { left: courses[i][k], right: courses[i][opponentIndex] }, courseIndex: i, }); courseMatches.push(match); @@ -116,7 +116,7 @@ export class GenerateMatchService { Match.new({ id: crypto.randomUUID(), matchType: "final", - teams: { Left: v[0].entry, Right: v[1].entry }, + teams: { left: v[0].entry, right: v[1].entry }, courseIndex: 0, }), ); @@ -128,7 +128,7 @@ export class GenerateMatchService { Match.new({ id: crypto.randomUUID(), matchType: "final", - teams: { Left: v[0].entry, Right: v[1].entry }, + teams: { left: v[0].entry, right: v[1].entry }, courseIndex: 0, }), ); @@ -161,8 +161,8 @@ export class GenerateMatchService { if (!isMatchResultPair(v.results)) continue; // 対戦の結果を取って、tournamentRankを作る - const left = v.results.Left; - const right = v.results.Right; + const left = v.results.left; + const right = v.results.right; // 左チームの結果を追加 const leftRank = rankBase.find((v) => v.entry.id === left.teamID); @@ -172,7 +172,7 @@ export class GenerateMatchService { rank: 0, points: left.points, time: left.time, - entry: v.teams.Left, + entry: v.teams.left, }); } else { // あれば足す @@ -188,7 +188,7 @@ export class GenerateMatchService { rank: 0, points: right.points, time: right.time, - entry: v.teams.Right, + entry: v.teams.right, }); } else { // あれば足す diff --git a/src/match/service/get.test.ts b/src/match/service/get.test.ts index 1644e46..d276bd5 100644 --- a/src/match/service/get.test.ts +++ b/src/match/service/get.test.ts @@ -16,7 +16,7 @@ describe("GetMatchService", () => { }); const match = Match.reconstruct({ id: "111", - teams: { Left: entry, Right: undefined }, + teams: { left: entry, right: undefined }, matchType: "primary", courseIndex: 0, }); @@ -42,14 +42,14 @@ describe("MatchDTO", async () => { const domain = Match.reconstruct({ id: "1", teams: { - Left: Entry.new({ + left: Entry.new({ id: "2", teamName: "あいうえお", members: ["いしや"], isMultiWalk: false, category: "Open", }), - Right: Entry.new({ + right: Entry.new({ id: "3", teamName: "いきしちに", members: ["やも"], @@ -60,12 +60,12 @@ describe("MatchDTO", async () => { matchType: "primary", courseIndex: 0, results: { - Left: { + left: { teamID: "2", points: 1, time: 10, }, - Right: { + right: { teamID: "3", points: 2, time: 20,