From 3b01f4c0ac764ecb70efaadfd939ca868c28769c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Jan 2021 14:42:43 +0100 Subject: Support progress for ffmpeg tasks --- server/controllers/api/jobs.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts index e14ea2575..929140140 100644 --- a/server/controllers/api/jobs.ts +++ b/server/controllers/api/jobs.ts @@ -52,28 +52,23 @@ async function listJobs (req: express.Request, res: express.Response) { const result: ResultList = { total, - data: state - ? jobs.map(j => formatJob(j, state)) - : await Promise.all(jobs.map(j => formatJobWithUnknownState(j))) + data: await Promise.all(jobs.map(j => formatJob(j, state))) } return res.json(result) } -async function formatJobWithUnknownState (job: any) { - return formatJob(job, await job.getState()) -} - -function formatJob (job: any, state: JobState): Job { +async function formatJob (job: any, state?: JobState): Promise { const error = isArray(job.stacktrace) && job.stacktrace.length !== 0 ? job.stacktrace[0] : null return { id: job.id, - state: state, + state: state || await job.getState(), type: job.queue.name as JobType, data: job.data, + progress: await job.progress(), error, createdAt: new Date(job.timestamp), finishedOn: new Date(job.finishedOn), -- cgit v1.2.3