fix api delayed jobs

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-08 10:31:14 +01:00
parent ff7c9a88bf
commit 8f03520645
3 changed files with 15 additions and 12 deletions

View File

@@ -1,13 +1,9 @@
import type { Queue } from 'bullmq';
import { redis } from '../../redis';
export async function findJobByPrefix<T>(
queue: Queue<T, any, string>,
matcher: string
) {
const prefix = `bull:${queue.name}:`;
const keys = await redis.keys(`${prefix}${matcher}*`);
const key = keys.findLast((key) => !key.endsWith(':logs'));
return key ? await queue.getJob(key.replace(prefix, '')) : undefined;
const delayed = await queue.getJobs('delayed');
return delayed.find((job) => job.opts.jobId?.startsWith(matcher));
}