feat: add OpenSkill and Glicko2 rating models to schema
This commit is contained in:
@@ -30,6 +30,9 @@ model Player {
|
|||||||
teamsAsPlayer1 Team[] @relation("TeamPlayer1")
|
teamsAsPlayer1 Team[] @relation("TeamPlayer1")
|
||||||
teamsAsPlayer2 Team[] @relation("TeamPlayer2")
|
teamsAsPlayer2 Team[] @relation("TeamPlayer2")
|
||||||
user User?
|
user User?
|
||||||
|
eloRating EloRating?
|
||||||
|
glicko2Rating Glicko2Rating?
|
||||||
|
openSkillRating OpenSkillRating?
|
||||||
|
|
||||||
@@map("players")
|
@@map("players")
|
||||||
}
|
}
|
||||||
@@ -276,3 +279,55 @@ model Verification {
|
|||||||
@@index([identifier])
|
@@index([identifier])
|
||||||
@@map("verification")
|
@@map("verification")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model EloRating {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
playerId Int @unique
|
||||||
|
rating Int @default(1000)
|
||||||
|
volatility Float @default(0) // Optional: for advanced Elo variants
|
||||||
|
gamesPlayed Int @default(0)
|
||||||
|
wins Int @default(0)
|
||||||
|
losses Int @default(0)
|
||||||
|
draws Int @default(0)
|
||||||
|
lastUpdated DateTime @default(now())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
player Player @relation(fields: [playerId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@map("elo_ratings")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Glicko2Rating {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
playerId Int @unique
|
||||||
|
rating Float @default(1500.0) // mu
|
||||||
|
deviation Float @default(350.0) // phi
|
||||||
|
volatility Float @default(0.05) // sigma
|
||||||
|
gamesPlayed Int @default(0)
|
||||||
|
wins Int @default(0)
|
||||||
|
losses Int @default(0)
|
||||||
|
draws Int @default(0)
|
||||||
|
lastUpdated DateTime @default(now())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
player Player @relation(fields: [playerId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@map("glicko2_ratings")
|
||||||
|
}
|
||||||
|
|
||||||
|
model OpenSkillRating {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
playerId Int @unique
|
||||||
|
rating Float @default(25.0) // mu
|
||||||
|
deviation Float @default(8.33) // sigma (std dev)
|
||||||
|
gamesPlayed Int @default(0)
|
||||||
|
wins Int @default(0)
|
||||||
|
losses Int @default(0)
|
||||||
|
draws Int @default(0)
|
||||||
|
lastUpdated DateTime @default(now())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
player Player @relation(fields: [playerId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@map("open_skill_ratings")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user