Block joining SendouQ if season's initial powers were never seeded

Closes #2395
This commit is contained in:
Kalle
2026-08-04 10:48:13 +03:00
parent c00fdeb35b
commit ff60e34c55
8 changed files with 80 additions and 14 deletions

View File

@@ -360,6 +360,9 @@ export function buildCases(fx: Fixtures): {
(skillBatch) =>
SkillRepository.findOrderedUserOrdinalsBySeason(skillBatch.season),
);
add("SkillRepository.existsBySeason", fx.skillBatch, (skillBatch) =>
SkillRepository.existsBySeason(skillBatch.season),
);
add("SkillRepository.findSeedingSkills", fx.skillBatch, (skillBatch) =>
SkillRepository.findSeedingSkills({
type: "RANKED",

View File

@@ -14,19 +14,12 @@ invariant(rawNth, "nth of new season needed (argument 1)");
const nth = Number(rawNth);
invariant(!Number.isNaN(nth), "nth of new season must be a number");
const seasonHasSkills = async (season: number) =>
Boolean(
await db
.selectFrom("Skill")
.select("id")
.where("season", "=", season)
.limit(1)
.executeTakeFirst(),
);
invariant(await seasonHasSkills(nth - 1), `No skills for season ${nth - 1}`);
invariant(
!(await seasonHasSkills(nth)),
await SkillRepository.existsBySeason(nth - 1),
`No skills for season ${nth - 1}`,
);
invariant(
!(await SkillRepository.existsBySeason(nth)),
`Skills for season ${nth} already exist`,
);