1
0
mirror of synced 2024-11-12 01:10:47 +01:00

ocm challenge prev champs

This commit is contained in:
ghkkk090 2022-08-15 18:48:54 +07:00
parent 617f8e8cc8
commit fe6b4efed9
3 changed files with 81 additions and 2 deletions

View File

@ -155,7 +155,7 @@ export default class CarModule extends Module {
announceEventModePrize: true,
opponentGhost: ghostCarsNo1 || null,
opponentTrailId: trailIdNo1 || null,
opponentCompetitionId: ocmEventDate!.competitionId || null
opponentCompetitionId: ocmEventDate?.competitionId || null
};
// Generate the load car response message

View File

@ -25,6 +25,31 @@ export default class StartupModule extends Module {
// Get current / previous active OCM Event
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
OR: [
{
// qualifyingPeriodStartAt is less than current date
qualifyingPeriodStartAt: { lte: date },
// qualifyingPeriodCloseAt is greater than current date
qualifyingPeriodCloseAt: { gte: date },
},
{
// competitionStartAt is less than current date
competitionStartAt: { lte: date },
// competitionCloseAt is greater than current date
competitionCloseAt: { gte: date },
},
{
// competitionCloseAt is less than current date
competitionCloseAt: { lte: date },
// competitionEndAt is greater than current date
competitionEndAt: {gte: date },
}
],
},
orderBy: [
{
dbId: 'desc'
@ -34,6 +59,21 @@ export default class StartupModule extends Module {
},
],
});
if(!(ocmEventDate))
{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: [
{
dbId: 'desc'
},
{
competitionEndAt: 'desc',
},
],
});
}
// Declare GhostCompetitionSchedule
let compeSch;
if(ocmEventDate)

View File

@ -11,8 +11,33 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
// Get current date
let date = Math.floor(new Date().getTime() / 1000);
// Get current active OCM Event
// Get current / previous active OCM Event
let ocmEventDate = await prisma.oCMEvent.findFirst({
where: {
OR: [
{
// qualifyingPeriodStartAt is less than current date
qualifyingPeriodStartAt: { lte: date },
// qualifyingPeriodCloseAt is greater than current date
qualifyingPeriodCloseAt: { gte: date },
},
{
// competitionStartAt is less than current date
competitionStartAt: { lte: date },
// competitionCloseAt is greater than current date
competitionCloseAt: { gte: date },
},
{
// competitionCloseAt is less than current date
competitionCloseAt: { lte: date },
// competitionEndAt is greater than current date
competitionEndAt: {gte: date },
}
],
},
orderBy: [
{
dbId: 'desc'
@ -23,6 +48,20 @@ export async function getOCMGhostTrail(carId: number, trailId: number)
],
});
if(!(ocmEventDate))
{
ocmEventDate = await prisma.oCMEvent.findFirst({
orderBy: [
{
dbId: 'desc'
},
{
competitionEndAt: 'desc',
},
],
});
}
let ghost_trails: OCMTop1GhostTrail | null;
// Current date is OCM main draw
if(ocmEventDate!.competitionStartAt < date && ocmEventDate!.competitionCloseAt > date)