Skip to content

Commit 6d5533b

Browse files
giovaborgognoclaude
andcommitted
fix(events): ClickHouse DateTime64 trailing 'Z' bug + ReplayEventsService tests
Fix ClickHouse DateTime64(3) parameter parsing — strip trailing 'Z' from ISO strings since DateTime64 without timezone specifier rejects it. Applied to ReplayEventsService and history endpoint. Add 6 integration tests for ReplayEventsService using containerTest (Postgres + Redis + ClickHouse testcontainers): - No events in range returns 0 - Dry run returns count without publishing - Replays events and triggers subscriber runs - EventFilter narrows replayed events - Malformed payloads are skipped gracefully - Tags from original events are preserved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ef2ec86 commit 6d5533b

File tree

3 files changed

+625
-5
lines changed

3 files changed

+625
-5
lines changed

apps/webapp/app/routes/api.v1.events.$eventId.history.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,23 @@ export const loader = createLoaderApiRoute(
4040
});
4141

4242
if (from) {
43-
queryBuilder.where("published_at >= {from: DateTime64(3)}", { from });
43+
queryBuilder.where("published_at >= {from: DateTime64(3)}", {
44+
from: from.replace("Z", ""),
45+
});
4446
}
4547

4648
if (to) {
47-
queryBuilder.where("published_at <= {to: DateTime64(3)}", { to });
49+
queryBuilder.where("published_at <= {to: DateTime64(3)}", { to: to.replace("Z", "") });
4850
}
4951

5052
if (publisherRunId) {
5153
queryBuilder.where("publisher_run_id = {publisherRunId: String}", { publisherRunId });
5254
}
5355

5456
if (cursor) {
55-
queryBuilder.where("published_at < {cursor: DateTime64(3)}", { cursor });
57+
queryBuilder.where("published_at < {cursor: DateTime64(3)}", {
58+
cursor: cursor.replace("Z", ""),
59+
});
5660
}
5761

5862
queryBuilder.orderBy("published_at DESC, event_id DESC").limit(limit + 1);

apps/webapp/app/v3/services/events/replayEvents.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export class ReplayEventsService extends BaseService {
6666
eventType: params.eventSlug,
6767
})
6868
.where("published_at >= {from: DateTime64(3)}", {
69-
from: params.from.toISOString(),
69+
from: params.from.toISOString().replace("Z", ""),
7070
})
7171
.where("published_at <= {to: DateTime64(3)}", {
72-
to: params.to.toISOString(),
72+
to: params.to.toISOString().replace("Z", ""),
7373
})
7474
.orderBy("published_at ASC, event_id ASC")
7575
.limit(MAX_REPLAY_EVENTS);

0 commit comments

Comments
 (0)