Skip to content

Commit 67aa496

Browse files
fix test and sort mongo query
1 parent 4e6e31e commit 67aa496

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/mongodb/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const createProcessorClient = <EventType extends string>(
3737
.find(filter)
3838
.project({ id: 1, errors: 1 })
3939
.limit(limit)
40+
.sort('timestamp', 'asc')
4041
.toArray()) as Pick<TxOBEvent<EventType>, "id" | "errors">[];
4142

4243
return events;

src/pg/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe("getEventsToProcess", () => {
2929
const result = await client.getEventsToProcess(opts);
3030
expect(pgClient.query).toHaveBeenCalledOnce();
3131
expect(pgClient.query).toHaveBeenCalledWith(
32-
'SELECT id, errors FROM "events" WHERE processed_at IS NULL AND (backoff_until IS NULL OR backoff_until < NOW()) AND errors < $1 LIMIT 100',
32+
'SELECT id, errors FROM "events" WHERE processed_at IS NULL AND (backoff_until IS NULL OR backoff_until < NOW()) AND errors < $1 ORDER BY timestamp ASC LIMIT 100',
3333
[opts.maxErrors],
3434
);
3535
expect(result).toBe(rows);

0 commit comments

Comments
 (0)