From f379e5e79e9e5cf190970aaf7bc291c8af0ac47e Mon Sep 17 00:00:00 2001 From: Artsiom Aliakseyenka Date: Fri, 5 Jan 2024 11:51:03 +0100 Subject: [PATCH] fix: add buffer for quering pending tasks (#2393) --- nestjs/src/courses/course-tasks/course-tasks.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nestjs/src/courses/course-tasks/course-tasks.service.ts b/nestjs/src/courses/course-tasks/course-tasks.service.ts index 694dc669ea..a824dd6775 100644 --- a/nestjs/src/courses/course-tasks/course-tasks.service.ts +++ b/nestjs/src/courses/course-tasks/course-tasks.service.ts @@ -134,16 +134,16 @@ export class CourseTasksService { public getTasksPendingDeadline( courseId: number, - { deadlineWithinHours = 24 }: { deadlineWithinHours?: number } = {}, + { deadlineWithinHours = 24, safeBuffer = 1 }: { deadlineWithinHours?: number; safeBuffer?: number } = {}, ) { - const now = dayjs().toISOString(); + const now = dayjs(); const endDate = dayjs().add(deadlineWithinHours, 'hours').toISOString(); const where: FindOptionsWhere = { courseId, disabled: false, - studentStartDate: LessThanOrEqual(now), - studentEndDate: Between(now, endDate), + studentStartDate: LessThanOrEqual(now.toISOString()), + studentEndDate: Between(now.add(safeBuffer, 'hours').toISOString(), endDate), }; return this.courseTaskRepository.find({