Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix:Right,Leftをright,leftに置換
Browse files Browse the repository at this point in the history
  • Loading branch information
kiharu3112 committed Jan 5, 2024
1 parent f3ebb0b commit 9c2f380
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 57 deletions.
12 changes: 6 additions & 6 deletions src/match/adaptor/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ interface matchResultJSON {
}

interface matchResultPairJSON {
Left: matchResultJSON;
Right: matchResultJSON;
left: matchResultJSON;
right: matchResultJSON;
}

interface matchResultFinalPairJSON {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/match/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -120,8 +120,8 @@ interface matchResultJSON {
}

interface matchResultPairJSON {
Left: matchResultJSON;
Right: matchResultJSON;
left: matchResultJSON;
right: matchResultJSON;
}

interface matchResultFinalPairJSON {
Expand Down
8 changes: 4 additions & 4 deletions src/match/match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/match/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -48,8 +48,8 @@ export type MatchResult = {
};
// 予選の結果
export type MatchResultPair = {
Left: MatchResult;
Right: MatchResult;
left: MatchResult;
right: MatchResult;
};
// 本選の結果
export type MatchResultFinalPair = {
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions src/match/service/edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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,
Expand All @@ -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,
Expand Down
40 changes: 20 additions & 20 deletions src/match/service/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("----------------------------------");
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions src/match/service/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}),
);
Expand All @@ -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,
}),
);
Expand Down Expand Up @@ -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);
Expand All @@ -172,7 +172,7 @@ export class GenerateMatchService {
rank: 0,
points: left.points,
time: left.time,
entry: v.teams.Left,
entry: v.teams.left,
});
} else {
// あれば足す
Expand All @@ -188,7 +188,7 @@ export class GenerateMatchService {
rank: 0,
points: right.points,
time: right.time,
entry: v.teams.Right,
entry: v.teams.right,
});
} else {
// あれば足す
Expand Down
10 changes: 5 additions & 5 deletions src/match/service/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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: ["やも"],
Expand All @@ -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,
Expand Down

0 comments on commit 9c2f380

Please sign in to comment.