From 891458c69e82b07692066dc1631f0637d4ad4738 Mon Sep 17 00:00:00 2001 From: julian-wasmeier-titanom Date: Tue, 21 May 2024 20:27:36 +0200 Subject: [PATCH] fix: ignore time in timestamp comparison --- backend/src/db/functions/assignment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/db/functions/assignment.ts b/backend/src/db/functions/assignment.ts index bbb0f29..3022885 100644 --- a/backend/src/db/functions/assignment.ts +++ b/backend/src/db/functions/assignment.ts @@ -73,7 +73,7 @@ export async function dbGetCurrentAssignmentsForTaskGroup(taskGroupId: number) { .innerJoin(taskTable, eq(taskTable.id, assignmentTable.taskId)) .innerJoin(taskGroupTable, eq(taskGroupTable.id, taskTable.taskGroupId)) .where( - sql`${assignmentTable.createdAt} >= NOW() - ${taskGroupTable.interval} AND ${taskGroupTable.id} = ${taskGroupId}`, + sql`${assignmentTable.createdAt}::date >= NOW()::date - ${taskGroupTable.interval} AND ${taskGroupTable.id} = ${taskGroupId}`, ); return currentAssignments; @@ -94,7 +94,7 @@ export async function dbGetTasksToAssignForCurrentInterval() { .having( or( eq(count(assignmentTable.id), 0), - sql`MAX(${assignmentTable.createdAt}) <= (NOW() - ${taskGroupTable.interval})`, + sql`MAX(${assignmentTable.createdAt})::date <= (NOW()::date - ${taskGroupTable.interval})`, ), );