diff --git a/scripts/recalculateSkills.ts b/scripts/recalculateSkills.ts index d246f30d3..17d8cf5e3 100644 --- a/scripts/recalculateSkills.ts +++ b/scripts/recalculateSkills.ts @@ -1,25 +1,19 @@ -import { Prisma, PrismaClient } from "@prisma/client"; +import { Prisma, PrismaClient, Skill } from "@prisma/client"; import { rating } from "openskill"; import { adjustSkills } from "~/core/mmr/utils"; import { groupsToWinningAndLosingPlayerIds } from "~/core/play/utils"; const prisma = new PrismaClient(); -type SkillWithDetails = { - mu: number; - sigma: number; - userId: string; - matchId: string; -}; type UserId = string; -type CurrentSkills = Record>; +type CurrentSkills = Record>; async function main() { const matches = (await allMatches()).filter((m) => m.stages.some((s) => s.winnerGroupId) ); - const newSkills: SkillWithDetails[] = []; + const newSkills: Omit[] = []; const currentSkills: CurrentSkills = {}; for (const match of matches) { @@ -41,7 +35,14 @@ async function main() { }), }); - newSkills.push(...adjustedSkills.map((s) => ({ ...s, matchId: match.id }))); + newSkills.push( + ...adjustedSkills.map((s) => ({ + ...s, + matchId: match.id, + tournamentId: null, + createdAt: match.createdAt, + })) + ); for (const skill of adjustedSkills) { const { userId, ...rest } = skill; @@ -69,7 +70,7 @@ function skillsPerUser({ }: { currentSkills: CurrentSkills; userIds: string[]; -}): Omit[] { +}): Pick[] { return userIds.map((id) => { const skill = currentSkills[id] ? currentSkills[id] : rating(); return { userId: id, ...skill };