try fix event.controller

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-07 22:18:50 +01:00
parent 6d5bfa4cbe
commit 4d17a29c2e
4 changed files with 147 additions and 117 deletions

View File

@@ -1,8 +1,13 @@
import type { Job } from 'bullmq';
import type { Queue } from 'bullmq';
export function findJobByPrefix<T>(
jobs: Job<T, any, string>[],
prefix: string
import { redis } from '../../redis';
export async function findJobByPrefix<T>(
queue: Queue<T, any, string>,
matcher: string
) {
return jobs.find((job) => job.opts.jobId?.startsWith(prefix));
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;
}