From 0224aae8c7d00453f7731cf2e0fb9936d016542f Mon Sep 17 00:00:00 2001 From: Shiroi Kitsu <108461408+ghkkk090@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:34:26 +0700 Subject: [PATCH] Update terminal.ts --- src/modules/terminal.ts | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/modules/terminal.ts b/src/modules/terminal.ts index c0e3ed0..4f6a3e5 100644 --- a/src/modules/terminal.ts +++ b/src/modules/terminal.ts @@ -631,30 +631,17 @@ export default class TerminalModule extends Module { { console.log('Current OCM Day : Competition Day / Main Draw'); - // Get Current OCM Period - let OCMCurrentPeriod = await prisma.oCMPeriod.findFirst({ - where: { - competitionDbId: ocmEventDate!.dbId, - competitionId: ocmEventDate!.competitionId, - startAt: - { - lte: date, // competitionStartAt is less than current date - }, - closeAt: - { - gte: date, // competitionCloseAt is greater than current date - } - } - }); - + // Get Current OCM Period and All User's Record let ocmParticipant = await prisma.oCMTally.findMany({ where:{ competitionId: ocmEventDate!.competitionId, - periodId: OCMCurrentPeriod!.periodId }, - orderBy: { - result: 'desc' - } + orderBy: [ + { + result: 'desc', + periodId: 'desc' + } + ] }) numOfParticipants = ocmParticipant.length; @@ -663,6 +650,8 @@ export default class TerminalModule extends Module { if(ocmParticipant) { + periodId = ocmParticipant[0].periodId; + for(let i=0; i