aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts7
-rw-r--r--server/lib/video.ts8
2 files changed, 7 insertions, 8 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 4ee2b2df2..010b95b05 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,7 +1,6 @@
1import * as Bull from 'bull' 1import * as Bull from 'bull'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { JOB_PRIORITY } from '@server/initializers/constants' 3import { getTranscodingJobPriority, publishAndFederateIfNeeded } from '@server/lib/video'
4import { getJobTranscodingPriorityMalus, publishAndFederateIfNeeded } from '@server/lib/video'
5import { getVideoFilePath } from '@server/lib/video-paths' 4import { getVideoFilePath } from '@server/lib/video-paths'
6import { UserModel } from '@server/models/account/user' 5import { UserModel } from '@server/models/account/user'
7import { MUser, MUserId, MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models' 6import { MUser, MUserId, MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/types/models'
@@ -215,7 +214,7 @@ async function createHlsJobIfEnabled (user: MUserId, payload: {
215 if (!payload || CONFIG.TRANSCODING.HLS.ENABLED !== true) return false 214 if (!payload || CONFIG.TRANSCODING.HLS.ENABLED !== true) return false
216 215
217 const jobOptions = { 216 const jobOptions = {
218 priority: JOB_PRIORITY.TRANSCODING.NEW_RESOLUTION + await getJobTranscodingPriorityMalus(user) 217 priority: await getTranscodingJobPriority(user)
219 } 218 }
220 219
221 const hlsTranscodingPayload: HLSTranscodingPayload = { 220 const hlsTranscodingPayload: HLSTranscodingPayload = {
@@ -272,7 +271,7 @@ async function createLowerResolutionsJobs (
272 resolutionCreated.push(resolution) 271 resolutionCreated.push(resolution)
273 272
274 const jobOptions = { 273 const jobOptions = {
275 priority: JOB_PRIORITY.TRANSCODING.NEW_RESOLUTION + await getJobTranscodingPriorityMalus(user) 274 priority: await getTranscodingJobPriority(user)
276 } 275 }
277 276
278 JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }, jobOptions) 277 JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput }, jobOptions)
diff --git a/server/lib/video.ts b/server/lib/video.ts
index e381e0a69..9469b8178 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -121,19 +121,19 @@ async function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile,
121 } 121 }
122 122
123 const jobOptions = { 123 const jobOptions = {
124 priority: JOB_PRIORITY.TRANSCODING.OPTIMIZER + await getJobTranscodingPriorityMalus(user) 124 priority: await getTranscodingJobPriority(user)
125 } 125 }
126 126
127 return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }, jobOptions) 127 return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }, jobOptions)
128} 128}
129 129
130async function getJobTranscodingPriorityMalus (user: MUserId) { 130async function getTranscodingJobPriority (user: MUserId) {
131 const now = new Date() 131 const now = new Date()
132 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7) 132 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
133 133
134 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek) 134 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
135 135
136 return videoUploadedByUser 136 return JOB_PRIORITY.TRANSCODING + videoUploadedByUser
137} 137}
138 138
139// --------------------------------------------------------------------------- 139// ---------------------------------------------------------------------------
@@ -144,5 +144,5 @@ export {
144 buildVideoThumbnailsFromReq, 144 buildVideoThumbnailsFromReq,
145 setVideoTags, 145 setVideoTags,
146 addOptimizeOrMergeAudioJob, 146 addOptimizeOrMergeAudioJob,
147 getJobTranscodingPriorityMalus 147 getTranscodingJobPriority
148} 148}