fix: remove dead DB UPDATE calls in conform worker

The jobs table row no longer exists for conform jobs (POST /jobs/conform
now goes directly to BullMQ). The UPDATE queries were no-ops (WHERE id = NULL)
so they're safe to remove. BullMQ tracks completed/failed status itself.
This commit is contained in:
Zac Gaetano 2026-05-18 23:28:13 -04:00
parent e895a2f2df
commit 7260b188c5

View file

@ -9,13 +9,14 @@ import { parseEDL } from '../edl/parser.js';
const S3_BUCKET = process.env.S3_BUCKET || 'wild-dragon'; const S3_BUCKET = process.env.S3_BUCKET || 'wild-dragon';
export const conformWorker = async (job) => { export const conformWorker = async (job) => {
const { jobId, edl, projectId, outputFormat } = job.data; const { edl, projectId, outputFormat } = job.data;
const jobId = job.id;
const tmpDir = tmpdir(); const tmpDir = tmpdir();
const edlPath = join(tmpDir, `edl-${job.id}.edl`); const edlPath = join(tmpDir, `edl-${jobId}.edl`);
const segmentsDir = join(tmpDir, `segments-${job.id}`); const segmentsDir = join(tmpDir, `segments-${jobId}`);
const segmentListPath = join(tmpDir, `segments-${job.id}.txt`); const segmentListPath = join(tmpDir, `segments-${jobId}.txt`);
const outputPath = join(tmpDir, `output-${job.id}.${outputFormat || 'mov'}`); const outputPath = join(tmpDir, `output-${jobId}.${outputFormat || 'mov'}`);
try { try {
// Write EDL to temp file // Write EDL to temp file
@ -47,7 +48,7 @@ export const conformWorker = async (job) => {
throw new Error(`Asset not found for reel: ${edit.reelName}`); throw new Error(`Asset not found for reel: ${edit.reelName}`);
} }
const { id: assetId, original_s3_key: sourceKey } = assetRes.rows[0]; const { original_s3_key: sourceKey } = assetRes.rows[0];
const segmentInputPath = join(segmentsDir, `segment-${edit.editNumber}-src`); const segmentInputPath = join(segmentsDir, `segment-${edit.editNumber}-src`);
const segmentOutputPath = join(segmentsDir, `segment-${edit.editNumber}.mov`); const segmentOutputPath = join(segmentsDir, `segment-${edit.editNumber}.mov`);
@ -84,23 +85,15 @@ export const conformWorker = async (job) => {
console.log(`[conform] Uploading output to ${outputKey}`); console.log(`[conform] Uploading output to ${outputKey}`);
await uploadToS3(S3_BUCKET, outputKey, outputPath); await uploadToS3(S3_BUCKET, outputKey, outputPath);
// Mark job complete
await job.updateProgress(95);
await query(
`UPDATE jobs SET status = 'complete', result = $1, updated_at = NOW() WHERE id = $2`,
[JSON.stringify({ output_key: outputKey }), jobId]
);
await job.updateProgress(100); await job.updateProgress(100);
console.log(`[conform] Job ${jobId} complete`); console.log(`[conform] Job ${jobId} complete → ${outputKey}`);
// Return value is stored by BullMQ and visible via GET /api/v1/jobs/:id
return { jobId, outputKey }; return { jobId, outputKey };
} catch (error) { } catch (error) {
console.error(`[conform] Error in job ${jobId}:`, error); console.error(`[conform] Error in job ${jobId}:`, error);
await query( // BullMQ marks the job failed automatically when we throw
`UPDATE jobs SET status = 'failed', error = $1, updated_at = NOW() WHERE id = $2`,
[error.message, jobId]
);
throw error; throw error;
} finally { } finally {