1 import { JOB_PRIORITY } from '@server/initializers/constants'
2 import { VideoModel } from '@server/models/video/video'
3 import { MUserId } from '@server/types/models'
5 export async function getTranscodingJobPriority (options: {
10 const { user, fallback, type } = options
12 if (!user) return fallback
14 const now = new Date()
15 const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
17 const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
19 const base = type === 'vod'
20 ? JOB_PRIORITY.TRANSCODING
21 : JOB_PRIORITY.VIDEO_STUDIO
23 return base + videoUploadedByUser