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

Commit

Permalink
fix: 試合生成時のバグ取り (#22)
Browse files Browse the repository at this point in the history
* fix: 試合生成時のバグ取り

* chore: format
  • Loading branch information
laminne authored Jan 5, 2024
1 parent 313c6c0 commit f3ebb0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/match/service/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("予選の対戦表を正しく生成できる", async () => {
const repository = new DummyRepository();
const matchRepository = new DummyMatchRepository();
const service = new GenerateMatchService(repository, matchRepository);
const dummyData = generateDummyData(10);
const dummyData = generateDummyData(32);
console.log(dummyData.length);
dummyData.map((v) => repository.create(v));

Expand All @@ -37,7 +37,13 @@ describe("予選の対戦表を正しく生成できる", async () => {
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);
console.log(
parseInt(j.teams.Left!.id) - 8,
parseInt(j.teams.Right!.id) - 8,
);
}
console.log("----------------------------------");
}
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/match/service/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export class GenerateMatchService {
}

// 分ける(N/M = A...B M[i]にA人、B人を少ない方から)
const entry = res[1];
const entry = res[1].filter((v) => v.category === "Elementary");
console.log(entry.length);
const entryNum = entry.length;
// コースごとの参加者数
const entryPerCourse = Math.floor(entryNum / this.COURSE_COUNT);
Expand Down

0 comments on commit f3ebb0b

Please sign in to comment.