Skip to content

Commit b734ee2

Browse files
committed
Add env var for partition window in seconds
1 parent 50444de commit b734ee2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

apps/webapp/app/env.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ const EnvironmentSchema = z.object({
483483
COMMON_WORKER_REDIS_CLUSTER_MODE_ENABLED: z.string().default("0"),
484484

485485
TASK_EVENT_PARTITIONING_ENABLED: z.string().default("0"),
486+
TASK_EVENT_PARTITIONED_WINDOW_IN_SECONDS: z.coerce.number().int().default(60), // 1 minute
486487
});
487488

488489
export type Environment = z.infer<typeof EnvironmentSchema>;

apps/webapp/app/v3/taskEventStore.server.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export class TaskEventStore {
8181

8282
if (table === "taskEventPartitioned" && startCreatedAt) {
8383
// Add 1 minute to endCreatedAt to make sure we include all events in the range.
84-
const end = endCreatedAt ? new Date(endCreatedAt.getTime() + 60_000) : new Date();
84+
const end = endCreatedAt
85+
? new Date(endCreatedAt.getTime() + env.TASK_EVENT_PARTITIONED_WINDOW_IN_SECONDS * 1000)
86+
: new Date();
8587

8688
finalWhere = {
8789
AND: [
@@ -140,7 +142,7 @@ export class TaskEventStore {
140142
"traceId" = ${traceId}
141143
AND "createdAt" >= ${startCreatedAt.toISOString()}::timestamp
142144
AND "createdAt" < ${(endCreatedAt
143-
? new Date(endCreatedAt.getTime() + 60_000)
145+
? new Date(endCreatedAt.getTime() + env.TASK_EVENT_PARTITIONED_WINDOW_IN_SECONDS * 1000)
144146
: new Date()
145147
).toISOString()}::timestamp
146148
ORDER BY "startTime" ASC

0 commit comments

Comments
 (0)