From c93050092c2f234dc1b9ca547ebea6d23c797d99 Mon Sep 17 00:00:00 2001 From: Shiroi Kitsu <108461408+shiroikitsu8@users.noreply.github.com> Date: Tue, 11 Jul 2023 09:43:55 +0700 Subject: [PATCH] fix period id not found (hopefully) --- flake.nix | 2 +- src/modules/ghost/ghost_history.ts | 42 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3169633..377d11c 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ in rec { packages.bayshore = pkgs.buildNpmPackage { pname = "bayshore"; - version = "1.1.0"; + version = "1.1.1"; src = ./.; npmDepsHash = "sha256-VbFdHmPF9we1MS8OibpJY51WKFUK3Iq9xNyb8GiBgL0="; diff --git a/src/modules/ghost/ghost_history.ts b/src/modules/ghost/ghost_history.ts index 5b149b7..522cef6 100644 --- a/src/modules/ghost/ghost_history.ts +++ b/src/modules/ghost/ghost_history.ts @@ -231,6 +231,27 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques } }); + // Period ID not found + if(!(OCM_periodId)) + { + OCM_periodId = await prisma.oCMPeriod.findFirst({ + where:{ + competitionId: ocmEventDate!.competitionId, + startAt: + { + lte: date - ocmEventDate!.lengthOfInterval, // competitionStartAt is less than current date + }, + closeAt: + { + gte: date - ocmEventDate!.lengthOfInterval, // competitionCloseAt is greater than current date + } + }, + select:{ + periodId: true + } + }); + } + let checkGhost = await prisma.oCMGhostBattleRecord.findFirst({ where:{ carId: saveExGhostHistory.carId, @@ -338,6 +359,27 @@ export async function saveOCMGhostHistory(body: wm.protobuf.SaveGameResultReques } }); + // Period ID not found + if(!(OCM_periodId)) + { + OCM_periodId = await prisma.oCMPeriod.findFirst({ + where:{ + competitionId: ocmEventDate!.competitionId, + startAt: + { + lte: date - ocmEventDate!.lengthOfInterval, // competitionStartAt is less than current date + }, + closeAt: + { + gte: date - ocmEventDate!.lengthOfInterval, // competitionCloseAt is greater than current date + } + }, + select:{ + periodId: true + } + }); + } + // Update ghost battle record await prisma.oCMGhostBattleRecord.create({ data: {