Skip to content

Commit 8b57c6d

Browse files
committed
fix(api): simplify date comparison in getDueCronTriggers using lte for improved clarity
1 parent d9d9b28 commit 8b57c6d

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

apps/api/src/db/queries.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
WorkflowExecutionStatus,
77
} from "@dafthunk/types";
88
import * as crypto from "crypto";
9-
import { and, desc, eq, inArray, SQL, sql } from "drizzle-orm";
9+
import { and, desc, eq, inArray, lte, SQL, sql } from "drizzle-orm";
1010
import { alias } from "drizzle-orm/sqlite-core";
1111
import { v7 as uuidv7 } from "uuid";
1212

@@ -1207,12 +1207,7 @@ export async function getDueCronTriggers(
12071207
selectedDeployment: selectedDeployment,
12081208
})
12091209
.from(cronTriggers)
1210-
.where(
1211-
and(
1212-
eq(cronTriggers.active, true),
1213-
sql`${cronTriggers.nextRunAt} <= ${Math.floor(now.getTime() / 1000)}`
1214-
)
1215-
)
1210+
.where(and(eq(cronTriggers.active, true), lte(cronTriggers.nextRunAt, now)))
12161211
.innerJoin(workflows, eq(workflows.id, cronTriggers.workflowId))
12171212
.innerJoin(latestByWorkflow, eq(latestByWorkflow.workflowId, workflows.id))
12181213
.innerJoin(

0 commit comments

Comments
 (0)