Jobs API: expose getJob and listRecentJobs; use unified queue module for job status and history; UI can query /api/jobs?ticker=...\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This commit is contained in:
2026-05-16 14:47:23 +02:00
parent 9771f48028
commit 669b792045
3 changed files with 33 additions and 6 deletions
+3 -5
View File
@@ -1,15 +1,13 @@
import { Queue } from "bullmq";
import { getJob } from "../../../lib/queue";
export async function loader({ params }: { params: { jobId: string } }) {
const jobId = params.jobId;
if (!jobId) return Response.json({ error: "jobId required" }, { status: 400 });
try {
const q = new Queue("analyze", { connection: process.env.REDIS_URL ? { connection: process.env.REDIS_URL } : undefined });
const job = await q.getJob(jobId);
const job = await getJob(jobId);
if (!job) return Response.json({ error: "Job not found" }, { status: 404 });
const state = await job.getState();
return Response.json({ id: job.id, state, failedReason: job.failedReason || null, returnValue: job.returnvalue || null });
return Response.json(job);
} catch (err) {
console.error("/api/jobs loader error:", err);
return Response.json({ error: "internal" }, { status: 500 });