Skip to content

Commit

Permalink
feat(queue): sort messages by timestamp asc
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Apr 10, 2024
1 parent b9dd4b5 commit 020135f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/queue/worker/github.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EmitterWebhookEventName, Webhooks } from '@octokit/webhooks';
import { orderBy, sortBy } from 'lodash';
import chunk from 'lodash/chunk';
import groupBy from 'lodash/groupBy';
import DefaultMap from 'mnemonist/default-map';
Expand Down Expand Up @@ -106,7 +107,10 @@ export class GitHubEventWorker extends BaseWorker<IGitHubEventQueueMessage> {
}

async run() {
const byId = groupBy(this.queue, (v) => v.body.botId);
const byId = groupBy(
orderBy(this.queue, 'timestamp', 'asc'),
(v) => v.body.botId,
);

const result = await Promise.allSettled(
Object.entries(byId).map(async ([botId, messages]) => {
Expand Down

0 comments on commit 020135f

Please sign in to comment.