( tableId: string, jobId: string, resultKey: string )
| 318 | * The download route reads it; the janitor deletes the file when the terminal job is pruned. |
| 319 | */ |
| 320 | export async function setJobResultKey( |
| 321 | tableId: string, |
| 322 | jobId: string, |
| 323 | resultKey: string |
| 324 | ): Promise<void> { |
| 325 | await db |
| 326 | .update(tableJobs) |
| 327 | .set({ |
| 328 | payload: sql`coalesce(${tableJobs.payload}, '{}'::jsonb) || jsonb_build_object('resultKey', ${resultKey}::text)`, |
| 329 | updatedAt: new Date(), |
| 330 | }) |
| 331 | .where(ownsActiveJob(tableId, jobId)) |
| 332 | } |
| 333 | |
| 334 | /** Shared WHERE for terminal transitions: this job run, and still in-flight (write-once). */ |
| 335 | function ownsActiveJob(tableId: string, jobId: string) { |
no test coverage detected