ocm challenge prev champs
This commit is contained in:
parent
617f8e8cc8
commit
fe6b4efed9
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user