2 import { JOB_PRIORITY } from '@server/initializers/constants'
3 import { VideoModel } from '@server/models/video/video'
4 import { MUserId, MVideoFile, MVideoFullLight } from '@server/types/models'
6 export abstract class AbstractJobBuilder {
8 abstract createOptimizeOrMergeAudioJobs (options: {
13 videoFileAlreadyLocked: boolean
16 abstract createTranscodingJobs (options: {
17 transcodingType: 'hls' | 'webtorrent'
18 video: MVideoFullLight
24 protected async getTranscodingJobPriority (options: {
28 const { user, fallback } = options
30 if (!user) return fallback
32 const now = new Date()
33 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
35 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
37 return JOB_PRIORITY.TRANSCODING + videoUploadedByUser