mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-11 13:46:10 -05:00
Block joining SendouQ if season's initial powers were never seeded
Closes #2395
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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`,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user