Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix jobs count

Chocobozzz47b9d52008f6
diff --git a/server/core/helpers/custom-validators/jobs.ts b/server/core/helpers/custom-validators/jobs.ts
index 6c5cc5e1cd..89023b73b0 100644
--- a/server/core/helpers/custom-validators/jobs.ts
+++ b/server/core/helpers/custom-validators/jobs.ts
@@ -2,30 +2,22 @@ import { JobState } from '@peertube/peertube-models'
import { jobTypes } from '@server/lib/job-queue/job-queue.js'
import { exists } from './misc.js'
-const jobStates = new Set<JobState>([
+export const allJobStates = new Set<JobState>([
'active',
'completed',
'failed',
'waiting',
'delayed',
+ 'wait',
'waiting-children',
'prioritized',
- 'wait',
'repeat'
])
-function isValidJobState (value: JobState) {
- return exists(value) && jobStates.has(value)
+export function isValidJobState (value: JobState) {
+ return exists(value) && allJobStates.has(value)
}
-function isValidJobType (value: any) {
+export function isValidJobType (value: any) {
return exists(value) && jobTypes.includes(value)
}
-
-// ---------------------------------------------------------------------------
-
-export {
- isValidJobState,
- isValidJobType,
- jobStates
-}
diff --git a/server/core/lib/job-queue/job-queue.ts b/server/core/lib/job-queue/job-queue.ts
index 91c576bc43..a978bbe7c1 100644
--- a/server/core/lib/job-queue/job-queue.ts
+++ b/server/core/lib/job-queue/job-queue.ts
@@ -28,7 +28,7 @@ import {
VideoTranscodingPayload,
VideoTranscriptionPayload
} from '@peertube/peertube-models'
-import { jobStates } from '@server/helpers/custom-validators/jobs.js'
+import { allJobStates } from '@server/helpers/custom-validators/jobs.js'
import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config.js'
import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy.js'
import {
@@ -515,7 +515,7 @@ class JobQueue {
const counts = await queue.getJobCounts()
for (const s of states) {
- total += counts[s]
+ total += counts[s] ?? 0
}
}
@@ -547,7 +547,7 @@ class JobQueue {
}
private buildStateFilter (state?: JobState) {
- if (!state) return Array.from(jobStates)
+ if (!state) return Array.from(allJobStates)
const states = [ state ]