refactor: enhance schedule and document handling in schemas
- Simplify schedule expiration logic in CronService by removing unnecessary date checks. - Improve error handling in DocumentSchema for document page retrieval, ensuring graceful failure. - Add validation in ScheduleSchema to restrict schedule retrieval to authorized centers and prevent subscription-based access. - Implement checks to reject schedules with start dates in the past or today, enhancing data integrity.
This commit is contained in:
@@ -165,7 +165,7 @@ export class CronService {
|
||||
Logger.log(`Found ${schedules.length} schedules to check`, 'taskCheckScheduleDateStart')
|
||||
for (const schedule of schedules) {
|
||||
await this.prisma.scheduleDate.updateMany({
|
||||
where: { scheduleId: schedule.id, start: { lt: DateTimeUtils.now().plus({ minutes: 30 }).toJSDate() } },
|
||||
where: { scheduleId: schedule.id },
|
||||
data: { status: ScheduleDateStatus.EXPIRED },
|
||||
})
|
||||
// update schedule status to expired
|
||||
@@ -183,7 +183,7 @@ export class CronService {
|
||||
'Lịch hướng dẫn của bạn đã hết hạn',
|
||||
`Lịch hướng dẫn với ngày bắt đầu: ${DateTimeUtils.format(
|
||||
DateTimeUtils.fromDate(schedule.scheduleStart),
|
||||
'DD/MM/YYYY',
|
||||
'D',
|
||||
)}, slot: ${schedule.slots.map((s) => s).join(', ')} của bạn đã hết hạn do không có học viên đăng ký, vui lòng tạo lịch hướng dẫn mới`,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user