1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Support progress for ffmpeg tasks

This commit is contained in:
Chocobozzz 2021-01-21 14:42:43 +01:00
parent d44cdcd766
commit 3b01f4c0ac
No known key found for this signature in database
GPG key ID: 583A612D890159BE
8 changed files with 71 additions and 34 deletions

View file

@ -52,28 +52,23 @@ async function listJobs (req: express.Request, res: express.Response) {
const result: ResultList<Job> = {
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<Job> {
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),