diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-05 09:25:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-05 09:32:20 +0200 |
commit | a6e37eebfbef9aef91e35173ed799afb6c4a288b (patch) | |
tree | facc792949953f70453f7c59af5c6fde97d4a45c /server/lib/video.ts | |
parent | 494e60804d15dfe1675d0390c8a7317911fd643f (diff) | |
download | PeerTube-a6e37eebfbef9aef91e35173ed799afb6c4a288b.tar.gz PeerTube-a6e37eebfbef9aef91e35173ed799afb6c4a288b.tar.zst PeerTube-a6e37eebfbef9aef91e35173ed799afb6c4a288b.zip |
Fix transcoding job priority
New resolution jobs are also important if waiting for transcoding is
enabled since we publish the video after the first resolution generation
Diffstat (limited to 'server/lib/video.ts')
-rw-r--r-- | server/lib/video.ts | 8 |
1 files changed, 4 insertions, 4 deletions
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 | ||
130 | async function getJobTranscodingPriorityMalus (user: MUserId) { | 130 | async 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 | } |