blob: 82ab6f2f12e7c606309ff44ee46dddc63ee5018d (
plain) (
tree)
|
|
import { JOB_PRIORITY } from '@server/initializers/constants'
import { VideoModel } from '@server/models/video/video'
import { MUserId } from '@server/types/models'
export async function getTranscodingJobPriority (options: {
user: MUserId
fallback: number
type: 'vod' | 'studio'
}) {
const { user, fallback, type } = options
if (!user) return fallback
const now = new Date()
const lastWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 7)
const videoUploadedByUser = await VideoModel.countVideosUploadedByUserSince(user.id, lastWeek)
const base = type === 'vod'
? JOB_PRIORITY.TRANSCODING
: JOB_PRIORITY.VIDEO_STUDIO
return base + videoUploadedByUser
}
|