mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Support studio transcoding in peertube runner
This commit is contained in:
parent
6a49056026
commit
5e47f6ab98
67 changed files with 1423 additions and 262 deletions
24
server/lib/transcoding/transcoding-priority.ts
Normal file
24
server/lib/transcoding/transcoding-priority.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue