Skip to content

Commit

Permalink
fix: add buffer for quering pending tasks (#2393)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaliakseyenka authored Jan 5, 2024
1 parent c6c42ea commit f379e5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nestjs/src/courses/course-tasks/course-tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CourseTask> = {
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({
Expand Down

0 comments on commit f379e5e

Please sign in to comment.