diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-02 11:00:40 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-02 11:13:13 +0100 |
commit | 7e7d8e485356402e7652c61c9f004e850b0a1607 (patch) | |
tree | 71c498c886cfd4b623a3c208572dc656ed800443 | |
parent | fd5fa94bbc808e3ebb7a2e6bca636f2607566b52 (diff) | |
download | PeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.tar.gz PeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.tar.zst PeerTube-7e7d8e485356402e7652c61c9f004e850b0a1607.zip |
Some fixes for admin videos list
12 files changed, 54 insertions, 54 deletions
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html index eedf6f3dc..dd4ab178e 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.html +++ b/client/src/app/+admin/overview/videos/video-list.component.html | |||
@@ -69,7 +69,7 @@ | |||
69 | 69 | ||
70 | <span *ngIf="video.nsfw" class="badge badge-red" i18n>NSFW</span> | 70 | <span *ngIf="video.nsfw" class="badge badge-red" i18n>NSFW</span> |
71 | 71 | ||
72 | <span *ngIf="isUnpublished(video.state.id)" class="badge badge-yellow" i18n>Not published yet</span> | 72 | <span *ngIf="isUnpublished(video.state.id)" class="badge badge-yellow" i18n>{{ video.state.label }}</span> |
73 | 73 | ||
74 | <span *ngIf="isAccountBlocked(video)" class="badge badge-red" i18n>Account muted</span> | 74 | <span *ngIf="isAccountBlocked(video)" class="badge badge-red" i18n>Account muted</span> |
75 | <span *ngIf="isServerBlocked(video)" class="badge badge-red" i18n>Server muted</span> | 75 | <span *ngIf="isServerBlocked(video)" class="badge badge-red" i18n>Server muted</span> |
@@ -80,8 +80,9 @@ | |||
80 | <td> | 80 | <td> |
81 | <span *ngIf="isHLS(video)" class="badge badge-blue">HLS</span> | 81 | <span *ngIf="isHLS(video)" class="badge badge-blue">HLS</span> |
82 | <span *ngIf="isWebTorrent(video)" class="badge badge-blue">WebTorrent</span> | 82 | <span *ngIf="isWebTorrent(video)" class="badge badge-blue">WebTorrent</span> |
83 | <span *ngIf="video.isLive" class="badge badge-blue">Live</span> | ||
83 | 84 | ||
84 | <span *ngIf="!video.remote">{{ getFilesSize(video) | bytes: 1 }}</span> | 85 | <span *ngIf="!video.isLive && video.isLocal">{{ getFilesSize(video) | bytes: 1 }}</span> |
85 | </td> | 86 | </td> |
86 | 87 | ||
87 | <td> | 88 | <td> |
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 6885abfc7..8bd171c53 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts | |||
@@ -16,7 +16,7 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
16 | videos: Video[] = [] | 16 | videos: Video[] = [] |
17 | 17 | ||
18 | totalRecords = 0 | 18 | totalRecords = 0 |
19 | sort: SortMeta = { field: 'publishedAt', order: 1 } | 19 | sort: SortMeta = { field: 'publishedAt', order: -1 } |
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
21 | 21 | ||
22 | bulkVideoActions: DropdownAction<Video[]>[][] = [] | 22 | bulkVideoActions: DropdownAction<Video[]>[][] = [] |
@@ -99,7 +99,7 @@ export class VideoListComponent extends RestTable implements OnInit { | |||
99 | } | 99 | } |
100 | 100 | ||
101 | isUnpublished (state: VideoState) { | 101 | isUnpublished (state: VideoState) { |
102 | return state !== VideoState.PUBLISHED | 102 | return state !== VideoState.LIVE_ENDED && state !== VideoState.PUBLISHED |
103 | } | 103 | } |
104 | 104 | ||
105 | isAccountBlocked (video: Video) { | 105 | isAccountBlocked (video: Video) { |
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 5db9a8704..819847ac6 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts | |||
@@ -48,7 +48,7 @@ export type CommonVideoParams = { | |||
48 | 48 | ||
49 | @Injectable() | 49 | @Injectable() |
50 | export class VideoService { | 50 | export class VideoService { |
51 | static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' | 51 | static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos' |
52 | static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.' | 52 | static BASE_FEEDS_URL = environment.apiUrl + '/feeds/videos.' |
53 | static BASE_SUBSCRIPTION_FEEDS_URL = environment.apiUrl + '/feeds/subscriptions.' | 53 | static BASE_SUBSCRIPTION_FEEDS_URL = environment.apiUrl + '/feeds/subscriptions.' |
54 | 54 | ||
@@ -60,18 +60,18 @@ export class VideoService { | |||
60 | ) {} | 60 | ) {} |
61 | 61 | ||
62 | getVideoViewUrl (uuid: string) { | 62 | getVideoViewUrl (uuid: string) { |
63 | return VideoService.BASE_VIDEO_URL + uuid + '/views' | 63 | return VideoService.BASE_VIDEO_URL + '/' + uuid + '/views' |
64 | } | 64 | } |
65 | 65 | ||
66 | getUserWatchingVideoUrl (uuid: string) { | 66 | getUserWatchingVideoUrl (uuid: string) { |
67 | return VideoService.BASE_VIDEO_URL + uuid + '/watching' | 67 | return VideoService.BASE_VIDEO_URL + '/' + uuid + '/watching' |
68 | } | 68 | } |
69 | 69 | ||
70 | getVideo (options: { videoId: string }): Observable<VideoDetails> { | 70 | getVideo (options: { videoId: string }): Observable<VideoDetails> { |
71 | return this.serverService.getServerLocale() | 71 | return this.serverService.getServerLocale() |
72 | .pipe( | 72 | .pipe( |
73 | switchMap(translations => { | 73 | switchMap(translations => { |
74 | return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + options.videoId) | 74 | return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + '/' + options.videoId) |
75 | .pipe(map(videoHash => ({ videoHash, translations }))) | 75 | .pipe(map(videoHash => ({ videoHash, translations }))) |
76 | }), | 76 | }), |
77 | map(({ videoHash, translations }) => new VideoDetails(videoHash, translations)), | 77 | map(({ videoHash, translations }) => new VideoDetails(videoHash, translations)), |
@@ -111,7 +111,7 @@ export class VideoService { | |||
111 | 111 | ||
112 | const data = objectToFormData(body) | 112 | const data = objectToFormData(body) |
113 | 113 | ||
114 | return this.authHttp.put(VideoService.BASE_VIDEO_URL + video.id, data) | 114 | return this.authHttp.put(VideoService.BASE_VIDEO_URL + '/' + video.id, data) |
115 | .pipe( | 115 | .pipe( |
116 | map(this.restExtractor.extractDataBool), | 116 | map(this.restExtractor.extractDataBool), |
117 | catchError(err => this.restExtractor.handleError(err)) | 117 | catchError(err => this.restExtractor.handleError(err)) |
@@ -119,7 +119,7 @@ export class VideoService { | |||
119 | } | 119 | } |
120 | 120 | ||
121 | uploadVideo (video: FormData) { | 121 | uploadVideo (video: FormData) { |
122 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + 'upload', video, { reportProgress: true }) | 122 | const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + '/' + 'upload', video, { reportProgress: true }) |
123 | 123 | ||
124 | return this.authHttp | 124 | return this.authHttp |
125 | .request<{ video: { id: number, uuid: string } }>(req) | 125 | .request<{ video: { id: number, uuid: string } }>(req) |
@@ -321,7 +321,7 @@ export class VideoService { | |||
321 | 321 | ||
322 | return from(ids) | 322 | return from(ids) |
323 | .pipe( | 323 | .pipe( |
324 | concatMap(id => this.authHttp.delete(VideoService.BASE_VIDEO_URL + id)), | 324 | concatMap(id => this.authHttp.delete(VideoService.BASE_VIDEO_URL + '/' + id)), |
325 | toArray(), | 325 | toArray(), |
326 | catchError(err => this.restExtractor.handleError(err)) | 326 | catchError(err => this.restExtractor.handleError(err)) |
327 | ) | 327 | ) |
@@ -413,7 +413,7 @@ export class VideoService { | |||
413 | } | 413 | } |
414 | 414 | ||
415 | private setVideoRate (id: number, rateType: UserVideoRateType) { | 415 | private setVideoRate (id: number, rateType: UserVideoRateType) { |
416 | const url = VideoService.BASE_VIDEO_URL + id + '/rate' | 416 | const url = VideoService.BASE_VIDEO_URL + '/' + id + '/rate' |
417 | const body: UserVideoRateUpdate = { | 417 | const body: UserVideoRateUpdate = { |
418 | rating: rateType | 418 | rating: rateType |
419 | } | 419 | } |
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 | ||
9 | export class AbstractVideosQueryBuilder { | 9 | export 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 @@ | |||
1 | import { createSafeIn } from '@server/models/utils' | 1 | import { createSafeIn } from '@server/models/utils' |
2 | import { MUserAccountId } from '@server/types/models' | 2 | import { MUserAccountId } from '@server/types/models' |
3 | import validator from 'validator' | 3 | import validator from 'validator' |
4 | import { AbstractVideosQueryBuilder } from './abstract-videos-query-builder' | 4 | import { AbstractRunQuery } from './abstract-run-query' |
5 | import { VideoTables } from './video-tables' | 5 | import { 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 | ||
13 | export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder { | 13 | export 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 @@ | |||
1 | import { Sequelize } from 'sequelize' | 1 | import { Sequelize } from 'sequelize' |
2 | import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder' | 2 | import { BuildVideoGetQueryOptions } from '../video-model-get-query-builder' |
3 | import { AbstractVideosModelQueryBuilder } from './abstract-videos-model-query-builder' | 3 | import { 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 | ||
11 | export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder { | 11 | export 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' | |||
18 | import { VideoFileModel } from '../../video-file' | 18 | import { VideoFileModel } from '../../video-file' |
19 | import { VideoLiveModel } from '../../video-live' | 19 | import { VideoLiveModel } from '../../video-live' |
20 | import { VideoStreamingPlaylistModel } from '../../video-streaming-playlist' | 20 | import { VideoStreamingPlaylistModel } from '../../video-streaming-playlist' |
21 | import { VideoTables } from './video-tables' | 21 | import { VideoTableAttributes } from './video-table-attributes' |
22 | 22 | ||
23 | type SQLRow = { [id: string]: string | number } | 23 | type 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 | */ |
7 | export class VideoTables { | 7 | export 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 () { |
diff --git a/server/models/video/sql/video-model-get-query-builder.ts b/server/models/video/sql/video-model-get-query-builder.ts index 2f34d5602..a65c96097 100644 --- a/server/models/video/sql/video-model-get-query-builder.ts +++ b/server/models/video/sql/video-model-get-query-builder.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { Sequelize, Transaction } from 'sequelize' | 1 | import { Sequelize, Transaction } from 'sequelize' |
2 | import { AbstractVideosModelQueryBuilder } from './shared/abstract-videos-model-query-builder' | 2 | import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder' |
3 | import { VideoFileQueryBuilder } from './shared/video-file-query-builder' | 3 | import { VideoFileQueryBuilder } from './shared/video-file-query-builder' |
4 | import { VideoModelBuilder } from './shared/video-model-builder' | 4 | import { VideoModelBuilder } from './shared/video-model-builder' |
5 | import { VideoTables } from './shared/video-tables' | 5 | import { VideoTableAttributes } from './shared/video-table-attributes' |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * | 8 | * |
@@ -46,7 +46,7 @@ export class VideoModelGetQueryBuilder { | |||
46 | this.webtorrentFilesQueryBuilder = new VideoFileQueryBuilder(sequelize) | 46 | this.webtorrentFilesQueryBuilder = new VideoFileQueryBuilder(sequelize) |
47 | this.streamingPlaylistFilesQueryBuilder = new VideoFileQueryBuilder(sequelize) | 47 | this.streamingPlaylistFilesQueryBuilder = new VideoFileQueryBuilder(sequelize) |
48 | 48 | ||
49 | this.videoModelBuilder = new VideoModelBuilder('get', new VideoTables('get')) | 49 | this.videoModelBuilder = new VideoModelBuilder('get', new VideoTableAttributes('get')) |
50 | } | 50 | } |
51 | 51 | ||
52 | async queryVideo (options: BuildVideoGetQueryOptions) { | 52 | async queryVideo (options: BuildVideoGetQueryOptions) { |
@@ -69,15 +69,16 @@ export class VideoModelGetQueryBuilder { | |||
69 | }) | 69 | }) |
70 | 70 | ||
71 | if (videos.length > 1) { | 71 | if (videos.length > 1) { |
72 | throw new Error('Video results is more than ') | 72 | throw new Error('Video results is more than 1') |
73 | } | 73 | } |
74 | 74 | ||
75 | if (videos.length === 0) return null | 75 | if (videos.length === 0) return null |
76 | |||
76 | return videos[0] | 77 | return videos[0] |
77 | } | 78 | } |
78 | } | 79 | } |
79 | 80 | ||
80 | export class VideosModelGetQuerySubBuilder extends AbstractVideosModelQueryBuilder { | 81 | export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder { |
81 | protected attributes: { [key: string]: string } | 82 | protected attributes: { [key: string]: string } |
82 | 83 | ||
83 | protected webtorrentFilesQuery: string | 84 | protected webtorrentFilesQuery: string |
diff --git a/server/models/video/sql/videos-id-list-query-builder.ts b/server/models/video/sql/videos-id-list-query-builder.ts index 4d6e0ea4b..5064afafe 100644 --- a/server/models/video/sql/videos-id-list-query-builder.ts +++ b/server/models/video/sql/videos-id-list-query-builder.ts | |||
@@ -5,7 +5,7 @@ import { WEBSERVER } from '@server/initializers/constants' | |||
5 | import { buildDirectionAndField, createSafeIn } from '@server/models/utils' | 5 | import { buildDirectionAndField, createSafeIn } from '@server/models/utils' |
6 | import { MUserAccountId, MUserId } from '@server/types/models' | 6 | import { MUserAccountId, MUserId } from '@server/types/models' |
7 | import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' | 7 | import { VideoInclude, VideoPrivacy, VideoState } from '@shared/models' |
8 | import { AbstractVideosQueryBuilder } from './shared/abstract-videos-query-builder' | 8 | import { AbstractRunQuery } from './shared/abstract-run-query' |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * | 11 | * |
@@ -72,7 +72,7 @@ export type BuildVideosListQueryOptions = { | |||
72 | having?: string | 72 | having?: string |
73 | } | 73 | } |
74 | 74 | ||
75 | export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { | 75 | export class VideosIdListQueryBuilder extends AbstractRunQuery { |
76 | protected replacements: any = {} | 76 | protected replacements: any = {} |
77 | 77 | ||
78 | private attributes: string[] | 78 | private attributes: string[] |
@@ -105,7 +105,7 @@ export class VideosIdListQueryBuilder extends AbstractVideosQueryBuilder { | |||
105 | return this.runQuery().then(rows => rows.length !== 0 ? rows[0].total : 0) | 105 | return this.runQuery().then(rows => rows.length !== 0 ? rows[0].total : 0) |
106 | } | 106 | } |
107 | 107 | ||
108 | getIdsListQueryAndSort (options: BuildVideosListQueryOptions) { | 108 | getQuery (options: BuildVideosListQueryOptions) { |
109 | this.buildIdsListQuery(options) | 109 | this.buildIdsListQuery(options) |
110 | 110 | ||
111 | return { query: this.query, sort: this.sort, replacements: this.replacements } | 111 | return { query: this.query, sort: this.sort, replacements: this.replacements } |
diff --git a/server/models/video/sql/videos-model-list-query-builder.ts b/server/models/video/sql/videos-model-list-query-builder.ts index cd721f055..b15b29ec3 100644 --- a/server/models/video/sql/videos-model-list-query-builder.ts +++ b/server/models/video/sql/videos-model-list-query-builder.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { VideoInclude } from '@shared/models' | 1 | import { VideoInclude } from '@shared/models' |
2 | import { Sequelize } from 'sequelize' | 2 | import { Sequelize } from 'sequelize' |
3 | import { AbstractVideosModelQueryBuilder } from './shared/abstract-videos-model-query-builder' | 3 | import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder' |
4 | import { VideoModelBuilder } from './shared/video-model-builder' | 4 | import { VideoModelBuilder } from './shared/video-model-builder' |
5 | import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder' | 5 | import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder' |
6 | 6 | ||
@@ -10,7 +10,7 @@ import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos- | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder { | 13 | export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder { |
14 | protected attributes: { [key: string]: string } | 14 | protected attributes: { [key: string]: string } |
15 | 15 | ||
16 | private innerQuery: string | 16 | private innerQuery: string |
@@ -26,7 +26,7 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder | |||
26 | 26 | ||
27 | queryVideos (options: BuildVideosListQueryOptions) { | 27 | queryVideos (options: BuildVideosListQueryOptions) { |
28 | this.buildInnerQuery(options) | 28 | this.buildInnerQuery(options) |
29 | this.buildListQueryFromIdsQuery(options) | 29 | this.buildMainQuery(options) |
30 | 30 | ||
31 | return this.runQuery() | 31 | return this.runQuery() |
32 | .then(rows => this.videoModelBuilder.buildVideosFromRows({ rows, include: options.include })) | 32 | .then(rows => this.videoModelBuilder.buildVideosFromRows({ rows, include: options.include })) |
@@ -34,14 +34,14 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder | |||
34 | 34 | ||
35 | private buildInnerQuery (options: BuildVideosListQueryOptions) { | 35 | private buildInnerQuery (options: BuildVideosListQueryOptions) { |
36 | const idsQueryBuilder = new VideosIdListQueryBuilder(this.sequelize) | 36 | const idsQueryBuilder = new VideosIdListQueryBuilder(this.sequelize) |
37 | const { query, sort, replacements } = idsQueryBuilder.getIdsListQueryAndSort(options) | 37 | const { query, sort, replacements } = idsQueryBuilder.getQuery(options) |
38 | 38 | ||
39 | this.replacements = replacements | 39 | this.replacements = replacements |
40 | this.innerQuery = query | 40 | this.innerQuery = query |
41 | this.innerSort = sort | 41 | this.innerSort = sort |
42 | } | 42 | } |
43 | 43 | ||
44 | private buildListQueryFromIdsQuery (options: BuildVideosListQueryOptions) { | 44 | private buildMainQuery (options: BuildVideosListQueryOptions) { |
45 | this.attributes = { | 45 | this.attributes = { |
46 | '"video".*': '' | 46 | '"video".*': '' |
47 | } | 47 | } |
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index cdb4dd343..e9e7e1757 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml | |||
@@ -4805,7 +4805,7 @@ components: | |||
4805 | required: false | 4805 | required: false |
4806 | schema: | 4806 | schema: |
4807 | type: boolean | 4807 | type: boolean |
4808 | description: 'Display only local or remote videos' | 4808 | description: '**PeerTube >= 4.0** Display only local or remote videos' |
4809 | include: | 4809 | include: |
4810 | name: include | 4810 | name: include |
4811 | in: query | 4811 | in: query |
@@ -4819,7 +4819,7 @@ components: | |||
4819 | - 4 | 4819 | - 4 |
4820 | - 8 | 4820 | - 8 |
4821 | description: > | 4821 | description: > |
4822 | Include additional videos in results (can be combined using bitwise or operator) | 4822 | **PeerTube >= 4.0** Include additional videos in results (can be combined using bitwise or operator) |
4823 | 4823 | ||
4824 | - `0` NONE | 4824 | - `0` NONE |
4825 | 4825 | ||