aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-02 11:00:40 +0100
committerChocobozzz <me@florianbigard.com>2021-11-02 11:13:13 +0100
commit7e7d8e485356402e7652c61c9f004e850b0a1607 (patch)
tree71c498c886cfd4b623a3c208572dc656ed800443 /server/models/video/sql/shared
parentfd5fa94bbc808e3ebb7a2e6bca636f2607566b52 (diff)
downloadPeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.tar.gz
PeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.tar.zst
PeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.zip
Some fixes for admin videos list
Diffstat (limited to 'server/models/video/sql/shared')
-rw-r--r--server/models/video/sql/shared/abstract-run-query.ts (renamed from server/models/video/sql/shared/abstract-videos-query-builder.ts)2
-rw-r--r--server/models/video/sql/shared/abstract-video-query-builder.ts (renamed from server/models/video/sql/shared/abstract-videos-model-query-builder.ts)10
-rw-r--r--server/models/video/sql/shared/video-file-query-builder.ts4
-rw-r--r--server/models/video/sql/shared/video-model-builder.ts4
-rw-r--r--server/models/video/sql/shared/video-table-attributes.ts (renamed from server/models/video/sql/shared/video-tables.ts)32
5 files changed, 25 insertions, 27 deletions
diff --git a/server/models/video/sql/shared/abstract-videos-query-builder.ts b/server/models/video/sql/shared/abstract-run-query.ts
index 09776bcb0..8e7a7642d 100644
--- a/server/models/video/sql/shared/abstract-videos-query-builder.ts
+++ b/server/models/video/sql/shared/abstract-run-query.ts
@@ -6,7 +6,7 @@ import { QueryTypes, Sequelize, Transaction } from 'sequelize'
6 * 6 *
7 */ 7 */
8 8
9export class AbstractVideosQueryBuilder { 9export class AbstractRunQuery {
10 protected sequelize: Sequelize 10 protected sequelize: Sequelize
11 11
12 protected query: string 12 protected query: string
diff --git a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts b/server/models/video/sql/shared/abstract-video-query-builder.ts
index 29827db2a..a6afb04e4 100644
--- a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts
+++ b/server/models/video/sql/shared/abstract-video-query-builder.ts
@@ -1,8 +1,8 @@
1import { createSafeIn } from '@server/models/utils' 1import { createSafeIn } from '@server/models/utils'
2import { MUserAccountId } from '@server/types/models' 2import { MUserAccountId } from '@server/types/models'
3import validator from 'validator' 3import validator from 'validator'
4import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' 4import { AbstractRunQuery } from './abstract-run-query'
5import { VideoTables } from './video-tables' 5import { VideoTableAttributes } from './video-table-attributes'
6 6
7/** 7/**
8 * 8 *
@@ -10,18 +10,18 @@ import { VideoTables } from './video-tables'
10 * 10 *
11 */ 11 */
12 12
13export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder { 13export class AbstractVideoQueryBuilder extends AbstractRunQuery {
14 protected attributes: { [key: string]: string } = {} 14 protected attributes: { [key: string]: string } = {}
15 15
16 protected joins = '' 16 protected joins = ''
17 protected where: string 17 protected where: string
18 18
19 protected tables: VideoTables 19 protected tables: VideoTableAttributes
20 20
21 constructor (protected readonly mode: 'list' | 'get') { 21 constructor (protected readonly mode: 'list' | 'get') {
22 super() 22 super()
23 23
24 this.tables = new VideoTables(this.mode) 24 this.tables = new VideoTableAttributes(this.mode)
25 } 25 }
26 26
27 protected buildSelect () { 27 protected buildSelect () {
diff --git a/server/models/video/sql/shared/video-file-query-builder.ts b/server/models/video/sql/shared/video-file-query-builder.ts
index 6b15c3b69..3eb3dc07d 100644
--- a/server/models/video/sql/shared/video-file-query-builder.ts
+++ b/server/models/video/sql/shared/video-file-query-builder.ts
@@ -1,6 +1,6 @@
1import { Sequelize } from 'sequelize' 1import { Sequelize } from 'sequelize'
2import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder' 2import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder'
3import { AbstractVideosModelQueryBuilder } from './abstract-videos-model-query-builder' 3import { AbstractVideoQueryBuilder } from './abstract-video-query-builder'
4 4
5/** 5/**
6 * 6 *
@@ -8,7 +8,7 @@ import { AbstractVideosModelQueryBuilder } from './abstract-videos-model-query-b
8 * 8 *
9 */ 9 */
10 10
11export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder { 11export class VideoFileQueryBuilder extends AbstractVideoQueryBuilder {
12 protected attributes: { [key: string]: string } 12 protected attributes: { [key: string]: string }
13 13
14 constructor (protected readonly sequelize: Sequelize) { 14 constructor (protected readonly sequelize: Sequelize) {
diff --git a/server/models/video/sql/shared/video-model-builder.ts b/server/models/video/sql/shared/video-model-builder.ts
index 0eac95661..7751d8e68 100644
--- a/server/models/video/sql/shared/video-model-builder.ts
+++ b/server/models/video/sql/shared/video-model-builder.ts
@@ -18,7 +18,7 @@ import { VideoChannelModel } from '../../video-channel'
18import { VideoFileModel } from '../../video-file' 18import { VideoFileModel } from '../../video-file'
19import { VideoLiveModel } from '../../video-live' 19import { VideoLiveModel } from '../../video-live'
20import { VideoStreamingPlaylistModel } from '../../video-streaming-playlist' 20import { VideoStreamingPlaylistModel } from '../../video-streaming-playlist'
21import { VideoTables } from './video-tables' 21import { VideoTableAttributes } from './video-table-attributes'
22 22
23type SQLRow = { [id: string]: string | number } 23type SQLRow = { [id: string]: string | number }
24 24
@@ -51,7 +51,7 @@ export class VideoModelBuilder {
51 51
52 constructor ( 52 constructor (
53 readonly mode: 'get' | 'list', 53 readonly mode: 'get' | 'list',
54 readonly tables: VideoTables 54 readonly tables: VideoTableAttributes
55 ) { 55 ) {
56 56
57 } 57 }
diff --git a/server/models/video/sql/shared/video-tables.ts b/server/models/video/sql/shared/video-table-attributes.ts
index 042b9d5da..8a8d2073a 100644
--- a/server/models/video/sql/shared/video-tables.ts
+++ b/server/models/video/sql/shared/video-table-attributes.ts
@@ -4,7 +4,7 @@
4 * Class to build video attributes/join names we want to fetch from the database 4 * Class to build video attributes/join names we want to fetch from the database
5 * 5 *
6 */ 6 */
7export class VideoTables { 7export class VideoTableAttributes {
8 8
9 constructor (readonly mode: 'get' | 'list') { 9 constructor (readonly mode: 'get' | 'list') {
10 10
@@ -93,22 +93,20 @@ export class VideoTables {
93 } 93 }
94 94
95 getStreamingPlaylistAttributes () { 95 getStreamingPlaylistAttributes () {
96 let playlistKeys = [ 'id', 'playlistUrl', 'playlistFilename', 'type' ] 96 return [
97 97 'id',
98 if (this.mode === 'get') { 98 'playlistUrl',
99 playlistKeys = playlistKeys.concat([ 99 'playlistFilename',
100 'p2pMediaLoaderInfohashes', 100 'type',
101 'p2pMediaLoaderPeerVersion', 101 'p2pMediaLoaderInfohashes',
102 'segmentsSha256Filename', 102 'p2pMediaLoaderPeerVersion',
103 'segmentsSha256Url', 103 'segmentsSha256Filename',
104 'videoId', 104 'segmentsSha256Url',
105 'createdAt', 105 'videoId',
106 'updatedAt', 106 'createdAt',
107 'storage' 107 'updatedAt',
108 ]) 108 'storage'
109 } 109 ]
110
111 return playlistKeys
112 } 110 }
113 111
114 getUserHistoryAttributes () { 112 getUserHistoryAttributes () {