diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-21 14:42:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-21 14:42:43 +0100 |
commit | 3b01f4c0ac764ecb70efaadfd939ca868c28769c (patch) | |
tree | 99c0cdef6dac0d43dd16c02b8bae3c132037cda6 /server/controllers | |
parent | d44cdcd766fbccbe4b96f34c11a64f0e2168c3b9 (diff) | |
download | PeerTube-3b01f4c0ac764ecb70efaadfd939ca868c28769c.tar.gz PeerTube-3b01f4c0ac764ecb70efaadfd939ca868c28769c.tar.zst PeerTube-3b01f4c0ac764ecb70efaadfd939ca868c28769c.zip |
Support progress for ffmpeg tasks
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/jobs.ts | 13 |
1 files changed, 4 insertions, 9 deletions
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) { | |||
52 | 52 | ||
53 | const result: ResultList<Job> = { | 53 | const result: ResultList<Job> = { |
54 | total, | 54 | total, |
55 | data: state | 55 | data: await Promise.all(jobs.map(j => formatJob(j, state))) |
56 | ? jobs.map(j => formatJob(j, state)) | ||
57 | : await Promise.all(jobs.map(j => formatJobWithUnknownState(j))) | ||
58 | } | 56 | } |
59 | 57 | ||
60 | return res.json(result) | 58 | return res.json(result) |
61 | } | 59 | } |
62 | 60 | ||
63 | async function formatJobWithUnknownState (job: any) { | 61 | async function formatJob (job: any, state?: JobState): Promise<Job> { |
64 | return formatJob(job, await job.getState()) | ||
65 | } | ||
66 | |||
67 | function formatJob (job: any, state: JobState): Job { | ||
68 | const error = isArray(job.stacktrace) && job.stacktrace.length !== 0 | 62 | const error = isArray(job.stacktrace) && job.stacktrace.length !== 0 |
69 | ? job.stacktrace[0] | 63 | ? job.stacktrace[0] |
70 | : null | 64 | : null |
71 | 65 | ||
72 | return { | 66 | return { |
73 | id: job.id, | 67 | id: job.id, |
74 | state: state, | 68 | state: state || await job.getState(), |
75 | type: job.queue.name as JobType, | 69 | type: job.queue.name as JobType, |
76 | data: job.data, | 70 | data: job.data, |
71 | progress: await job.progress(), | ||
77 | error, | 72 | error, |
78 | createdAt: new Date(job.timestamp), | 73 | createdAt: new Date(job.timestamp), |
79 | finishedOn: new Date(job.finishedOn), | 74 | finishedOn: new Date(job.finishedOn), |