jobs: show target path in list rows; delete queued/finished jobs + clear-all history

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 16:31:52 +00:00
co-authored by Claude Opus 4.8
parent 5da29e4004
commit 32caa67cab
5 changed files with 95 additions and 24 deletions
+2
View File
@@ -79,6 +79,8 @@ export {
getPipelineJobsForUser,
getOldestPendingJob,
countPendingJobs,
deletePipelineJob,
deleteTerminalJobsForUser,
markInterruptedJobs,
} from './queries/pipeline-jobs';
@@ -1,4 +1,6 @@
import { eq, and, asc, desc } from 'drizzle-orm';
import { eq, and, inArray, asc, desc } from 'drizzle-orm';
const TERMINAL_STATUSES = ['completed', 'failed', 'stopped', 'interrupted'] as const;
import { db } from '../db';
import { pipelineJobs } from '../schema/pipeline-jobs';
import type { PipelineJobInsert } from '../types';
@@ -26,6 +28,20 @@ export async function getPipelineJobsForUser(userId: number, limit = 50) {
.limit(limit);
}
// Delete a single job row.
export async function deletePipelineJob(id: string) {
await db.delete(pipelineJobs).where(eq(pipelineJobs.id, id));
}
// Delete all of a user's finished jobs (history); returns the deleted ids so their logs can be removed.
export async function deleteTerminalJobsForUser(userId: number) {
const rows = await db
.delete(pipelineJobs)
.where(and(eq(pipelineJobs.userId, userId), inArray(pipelineJobs.status, [...TERMINAL_STATUSES])))
.returning({ id: pipelineJobs.id });
return rows.map((r) => r.id);
}
// Count of the user's queued (pending) jobs — for the header badge.
export async function countPendingJobs(userId: number) {
const rows = await db