diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:09:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:09:52 +0200 |
commit | 71d4af1efc810f853e1a0d986bf758c201692594 (patch) | |
tree | 2066053638baefb6430772c2e0a0aa1774019a51 /server/lib | |
parent | 3c79c2ce86eaf9e151ab6c2c9d1f646968a16744 (diff) | |
download | PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.tar.gz PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.tar.zst PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.zip |
Use raw SQL for most of video queries
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/model-loaders/video.ts | 13 |
1 files changed, 5 insertions, 8 deletions
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 { | |||
3 | MVideoAccountLightBlacklistAllFiles, | 3 | MVideoAccountLightBlacklistAllFiles, |
4 | MVideoFormattableDetails, | 4 | MVideoFormattableDetails, |
5 | MVideoFullLight, | 5 | MVideoFullLight, |
6 | MVideoIdThumbnail, | 6 | MVideoId, |
7 | MVideoImmutable, | 7 | MVideoImmutable, |
8 | MVideoThumbnail, | 8 | MVideoThumbnail, |
9 | MVideoWithRights | 9 | MVideoWithRights |
10 | } from '@server/types/models' | 10 | } from '@server/types/models' |
11 | import { Hooks } from '../plugins/hooks' | 11 | import { Hooks } from '../plugins/hooks' |
12 | 12 | ||
13 | type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 13 | type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'id' | 'none' | 'only-immutable-attributes' |
14 | 14 | ||
15 | function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails> | 15 | function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails> |
16 | function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> | 16 | function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> |
17 | function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> | 17 | function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
18 | function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> | 18 | function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> |
19 | function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights> | 19 | function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoId> |
20 | function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail> | ||
21 | function loadVideo ( | 20 | function loadVideo ( |
22 | id: number | string, | 21 | id: number | string, |
23 | fetchType: VideoLoadType, | 22 | fetchType: VideoLoadType, |
24 | userId?: number | 23 | userId?: number |
25 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> | 24 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable> |
26 | function loadVideo ( | 25 | function loadVideo ( |
27 | id: number | string, | 26 | id: number | string, |
28 | fetchType: VideoLoadType, | 27 | fetchType: VideoLoadType, |
29 | userId?: number | 28 | userId?: number |
30 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { | 29 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable> { |
31 | 30 | ||
32 | if (fetchType === 'for-api') { | 31 | if (fetchType === 'for-api') { |
33 | return Hooks.wrapPromiseFun( | 32 | return Hooks.wrapPromiseFun( |
@@ -41,8 +40,6 @@ function loadVideo ( | |||
41 | 40 | ||
42 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) | 41 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) |
43 | 42 | ||
44 | if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id) | ||
45 | |||
46 | if (fetchType === 'only-video') return VideoModel.load(id) | 43 | if (fetchType === 'only-video') return VideoModel.load(id) |
47 | 44 | ||
48 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) | 45 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) |