bling bling
This commit is contained in:
@@ -30,33 +30,43 @@ export class CronService {
|
||||
`Found ${schedules.length} schedules to update`,
|
||||
'checkScheduleDateStatus',
|
||||
)
|
||||
// get all collaboration sessions
|
||||
const collaborationSessions =
|
||||
await this.prisma.collaborationSession.findMany({
|
||||
where: {
|
||||
collaboratorsIds: {
|
||||
hasEvery: schedules.map((s) => s.id),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const updates = schedules
|
||||
.map((schedule) => {
|
||||
if (schedule.status === ScheduleDateStatus.NOT_STARTED) {
|
||||
const collaborationSession = collaborationSessions.find(
|
||||
(session) => session.scheduleDateId === schedule.id,
|
||||
)
|
||||
|
||||
if (!collaborationSession) {
|
||||
return {
|
||||
id: schedule.id,
|
||||
status: ScheduleDateStatus.MISSING_MENTOR,
|
||||
}
|
||||
}
|
||||
if (
|
||||
schedule.status === ScheduleDateStatus.IN_PROGRESS &&
|
||||
schedule.participantIds.length === 1
|
||||
) {
|
||||
|
||||
if (collaborationSession.collaboratorsIds.length === 1) {
|
||||
return {
|
||||
id: schedule.id,
|
||||
status: ScheduleDateStatus.MISSING_CUSTOMER,
|
||||
}
|
||||
}
|
||||
if (
|
||||
schedule.status === ScheduleDateStatus.IN_PROGRESS &&
|
||||
schedule.participantIds.length === 2
|
||||
) {
|
||||
|
||||
if (collaborationSession.collaboratorsIds.length === 2) {
|
||||
return {
|
||||
id: schedule.id,
|
||||
status: ScheduleDateStatus.COMPLETED,
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
.filter((update) => update !== null)
|
||||
|
||||
Reference in New Issue
Block a user