From 71d4af1efc810f853e1a0d986bf758c201692594 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Jun 2021 14:09:33 +0200 Subject: Use raw SQL for most of video queries --- server/lib/model-loaders/video.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'server/lib/model-loaders') diff --git a/server/lib/model-loaders/video.ts b/server/lib/model-loaders/video.ts index 07b373ed3..e2bf96f62 100644 --- a/server/lib/model-loaders/video.ts +++ b/server/lib/model-loaders/video.ts @@ -3,31 +3,30 @@ import { MVideoAccountLightBlacklistAllFiles, MVideoFormattableDetails, MVideoFullLight, - MVideoIdThumbnail, + MVideoId, MVideoImmutable, MVideoThumbnail, MVideoWithRights } from '@server/types/models' import { Hooks } from '../plugins/hooks' -type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' +type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'id' | 'none' | 'only-immutable-attributes' function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise -function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise -function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise +function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise function loadVideo ( id: number | string, fetchType: VideoLoadType, userId?: number -): Promise +): Promise function loadVideo ( id: number | string, fetchType: VideoLoadType, userId?: number -): Promise { +): Promise { if (fetchType === 'for-api') { return Hooks.wrapPromiseFun( @@ -41,8 +40,6 @@ function loadVideo ( if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) - if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id) - if (fetchType === 'only-video') return VideoModel.load(id) if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) -- cgit v1.2.3