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: {
15 abstract createTranscodingJobs (options: {
16 transcodingType: 'hls' | 'webtorrent'
17 video: MVideoFullLight
23 protected async getTranscodingJobPriority (options: {
27 const { user, fallback } = options
29 if (!user) return fallback
31 const now = new Date()
32 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
34 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
36 return JOB_PRIORITY.TRANSCODING + videoUploadedByUser