import * as Bull from 'bull'
+import { jobStates } from '@server/helpers/custom-validators/jobs'
+import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy'
import {
ActivitypubFollowPayload,
ActivitypubHttpBroadcastPayload,
VideoTranscodingPayload
} from '../../../shared/models'
import { logger } from '../../helpers/logger'
-import { Redis } from '../redis'
import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants'
+import { Redis } from '../redis'
+import { processActivityPubFollow } from './handlers/activitypub-follow'
import { processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast'
import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher'
import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast'
-import { processEmail } from './handlers/email'
-import { processVideoTranscoding } from './handlers/video-transcoding'
-import { processActivityPubFollow } from './handlers/activitypub-follow'
-import { processVideoImport } from './handlers/video-import'
-import { processVideosViews } from './handlers/video-views'
import { refreshAPObject } from './handlers/activitypub-refresher'
+import { processEmail } from './handlers/email'
import { processVideoFileImport } from './handlers/video-file-import'
-import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy'
+import { processVideoImport } from './handlers/video-import'
import { processVideoLiveEnding } from './handlers/video-live-ending'
+import { processVideoTranscoding } from './handlers/video-transcoding'
+import { processVideosViews } from './handlers/video-views'
type CreateJobArgument =
{ type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } |
}
async listForApi (options: {
- state: JobState
+ state?: JobState
start: number
count: number
asc?: boolean
jobType: JobType
}): Promise<Bull.Job[]> {
const { state, start, count, asc, jobType } = options
+
+ const states = state ? [ state ] : jobStates
let results: Bull.Job[] = []
const filteredJobTypes = this.filterJobTypes(jobType)
continue
}
- const jobs = await queue.getJobs([ state ], 0, start + count, asc)
+ const jobs = await queue.getJobs(states, 0, start + count, asc)
results = results.concat(jobs)
}
}
async count (state: JobState, jobType?: JobType): Promise<number> {
+ const states = state ? [ state ] : jobStates
let total = 0
const filteredJobTypes = this.filterJobTypes(jobType)
const counts = await queue.getJobCounts()
- total += counts[state]
+ for (const s of states) {
+ total += counts[s]
+ }
}
return total