Skip to content

Commit

Permalink
cleaner waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
Bossett committed Sep 9, 2024
1 parent 4b402bd commit 3b3ff95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/labelEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const waitTime =

export default async function labelEmitter() {
do {
const minWait = (async () => await wait(waitTime))()
const promArray: Promise<any>[] = [wait(waitTime)]
const events = await db.query.label_actions.findMany({
where: lte(
schema.label_actions.unixtimescheduled,
Expand All @@ -46,11 +46,11 @@ export default async function labelEmitter() {
const [completedEvents, groupedEvents, eventLog] = await processEvents(
events,
)
await Promise.allSettled([
logAndCleanup(completedEvents, groupedEvents, eventLog),
minWait,
])
} else await minWait
promArray.push(logAndCleanup(completedEvents, groupedEvents, eventLog))
}

await Promise.allSettled(promArray)
promArray.length = 0
} while (true)
}

Expand Down

0 comments on commit 3b3ff95

Please sign in to comment.