From 77d7e851dccf17dcc89e8fcc2db3f655d1e63f95 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Jan 2021 16:57:21 +0100 Subject: Add priority to transcoding jobs (1 = highest priority) 100 for new resolutions 10 for original file optimization Add a malus for transcoding jobs depending on how many uploads the user did in the last 7 days --- server/helpers/database-utils.ts | 8 ++++++++ server/helpers/video.ts | 28 +--------------------------- 2 files changed, 9 insertions(+), 27 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 87f10f913..2b916efc2 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts @@ -4,6 +4,14 @@ import { Model } from 'sequelize-typescript' import { logger } from './logger' import { Transaction } from 'sequelize' +function retryTransactionWrapper ( + functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise | Bluebird, + arg1: A, + arg2: B, + arg3: C, + arg4: D, +): Promise + function retryTransactionWrapper ( functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise | Bluebird, arg1: A, diff --git a/server/helpers/video.ts b/server/helpers/video.ts index bfd5a9627..7c510f474 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -1,20 +1,17 @@ import { Response } from 'express' import { CONFIG } from '@server/initializers/config' -import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' -import { JobQueue } from '@server/lib/job-queue' import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoAccountLightBlacklistAllFiles, - MVideoFile, MVideoFullLight, MVideoIdThumbnail, MVideoImmutable, MVideoThumbnail, MVideoWithRights } from '@server/types/models' -import { VideoPrivacy, VideoState, VideoTranscodingPayload } from '@shared/models' +import { VideoPrivacy, VideoState } from '@shared/models' import { VideoModel } from '../models/video/video' type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' @@ -69,27 +66,6 @@ function getVideoWithAttributes (res: Response) { return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights } -function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) { - let dataInput: VideoTranscodingPayload - - if (videoFile.isAudio()) { - dataInput = { - type: 'merge-audio-to-webtorrent', - resolution: DEFAULT_AUDIO_RESOLUTION, - videoUUID: video.uuid, - isNewVideo: true - } - } else { - dataInput = { - type: 'optimize-to-webtorrent', - videoUUID: video.uuid, - isNewVideo: true - } - } - - return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) -} - function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { return isStreamingPlaylist(videoOrPlaylist) ? videoOrPlaylist.Video @@ -107,7 +83,6 @@ function isStateForFederation (state: VideoState) { const castedState = parseInt(state + '', 10) return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED - } function getPrivaciesForFederation () { @@ -130,7 +105,6 @@ export { fetchVideo, getVideoWithAttributes, fetchVideoByUrl, - addOptimizeOrMergeAudioJob, extractVideo, getExtFromMimetype, isStateForFederation, -- cgit v1.2.3