Skip to content

Commit

Permalink
Add parsing for gems and killer_flags
Browse files Browse the repository at this point in the history
  • Loading branch information
O4epegb committed Oct 27, 2024
1 parent 7c1866c commit 78c77e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/api/prisma/migrations/20241027154632_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "Game" ADD COLUMN "gems" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN "intactGems" INTEGER NOT NULL DEFAULT 0,
ADD COLUMN "killerType" TEXT;
2 changes: 2 additions & 0 deletions apps/api/prisma/migrations/20241027154830_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- One time operation to reparse all logfiles and add new fields
UPDATE "Logfile" SET "bytesRead" = 0;
3 changes: 3 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ model Game {
duration Int
uniqueRunes Int
runes Int
gems Int @default(0)
intactGems Int @default(0)
branch String
lvl Int
fifteenskills String[]
Expand All @@ -79,6 +81,7 @@ model Game {
god String?
piety Int?
killer String?
killerType String?
scrollsused Int?
potionsused Int?
gold Int?
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/parser/processGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export const processGames = async (file: LogfileWithServer, lines: string[]) =>
duration: Number(rawGame.dur),
runes: Number(rawGame.nrune),
uniqueRunes: Number(rawGame.urune),
gems: Number(rawGame.fgem),
intactGems: Number(rawGame.igem),
branch: rawGame.br,
lvl: Number(rawGame.lvl),
piety: rawGame.piety !== null ? parseInt(rawGame.piety, 10) : null,
Expand All @@ -113,6 +115,7 @@ export const processGames = async (file: LogfileWithServer, lines: string[]) =>
ev: rawGame.ev !== null ? Number(rawGame.ev) : null,
sh: rawGame.sh !== null ? Number(rawGame.sh) : null,
killer: rawGame.killer,
killerType: rawGame.killerType,
scrollsused: rawGame.scrollsused !== null ? Number(rawGame.scrollsused) : null,
potionsused: rawGame.potionsused !== null ? Number(rawGame.potionsused) : null,
gold: rawGame.gold !== null ? Number(rawGame.gold) : null,
Expand Down
6 changes: 6 additions & 0 deletions apps/api/src/parser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ export type ParsedGame = RequiredKeysMap & {
piety: string | null
nrune: string
urune: string
fgem: string
igem: string
fifteenskills: string | null
maxskills: string | null
ac: string | null
ev: string | null
sh: string | null
killer: string | null
killerType: string | null
scrollsused: string | null
potionsused: string | null
gold: string | null
Expand All @@ -92,12 +95,15 @@ export const getGameFromCandidate = (candidate: Record<string, string>): ParsedG
piety: candidate.piety || null,
nrune: candidate.nrune || candidate.urune || '0',
urune: candidate.urune || candidate.nrune || '0',
fgem: candidate.fgem || '0',
igem: candidate.igem || '0',
fifteenskills: candidate.fifteenskills || null,
maxskills: candidate.maxskills || null,
ac: candidate.ac || null,
ev: candidate.ev || null,
sh: candidate.sh || null,
killer: candidate.killer || null,
killerType: candidate.killer_flags === 'unique' ? candidate.killer_flags : null,
scrollsused: candidate.scrollsused || null,
potionsused: candidate.potionsused || null,
gold: candidate.gold || null,
Expand Down

0 comments on commit 78c77e0

Please sign in to comment.