mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
24
server/core/lib/transcoding/transcoding-priority.ts
Normal file
24
server/core/lib/transcoding/transcoding-priority.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { JOB_PRIORITY } from '@server/initializers/constants.js'
|
||||
import { VideoModel } from '@server/models/video/video.js'
|
||||
import { MUserId } from '@server/types/models/index.js'
|
||||
|
||||
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