aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/redundancy
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/redundancy')
-rw-r--r--server/models/redundancy/video-redundancy.ts58
1 files changed, 29 insertions, 29 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index 4e66d72e3..1b63d3818 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -43,7 +43,7 @@ export enum ScopeNames {
43} 43}
44 44
45@Scopes(() => ({ 45@Scopes(() => ({
46 [ ScopeNames.WITH_VIDEO ]: { 46 [ScopeNames.WITH_VIDEO]: {
47 include: [ 47 include: [
48 { 48 {
49 model: VideoFileModel, 49 model: VideoFileModel,
@@ -167,7 +167,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
167 logger.info('Removing duplicated video streaming playlist %s.', videoUUID) 167 logger.info('Removing duplicated video streaming playlist %s.', videoUUID)
168 168
169 videoStreamingPlaylist.Video.removeStreamingPlaylistFiles(videoStreamingPlaylist, true) 169 videoStreamingPlaylist.Video.removeStreamingPlaylistFiles(videoStreamingPlaylist, true)
170 .catch(err => logger.error('Cannot delete video streaming playlist files of %s.', videoUUID, { err })) 170 .catch(err => logger.error('Cannot delete video streaming playlist files of %s.', videoUUID, { err }))
171 } 171 }
172 172
173 return undefined 173 return undefined
@@ -230,12 +230,12 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
230 }, 230 },
231 include: [ 231 include: [
232 { 232 {
233 attributes: [ ], 233 attributes: [],
234 model: VideoFileModel, 234 model: VideoFileModel,
235 required: true, 235 required: true,
236 include: [ 236 include: [
237 { 237 {
238 attributes: [ ], 238 attributes: [],
239 model: VideoModel, 239 model: VideoModel,
240 required: true, 240 required: true,
241 where: { 241 where: {
@@ -248,7 +248,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
248 } 248 }
249 249
250 return VideoRedundancyModel.findOne(query) 250 return VideoRedundancyModel.findOne(query)
251 .then(r => !!r) 251 .then(r => !!r)
252 } 252 }
253 253
254 static async getVideoSample (p: Bluebird<VideoModel[]>) { 254 static async getVideoSample (p: Bluebird<VideoModel[]>) {
@@ -310,7 +310,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
310 where: { 310 where: {
311 privacy: VideoPrivacy.PUBLIC, 311 privacy: VideoPrivacy.PUBLIC,
312 views: { 312 views: {
313 [ Op.gte ]: minViews 313 [Op.gte]: minViews
314 } 314 }
315 }, 315 },
316 include: [ 316 include: [
@@ -333,7 +333,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
333 actorId: actor.id, 333 actorId: actor.id,
334 strategy, 334 strategy,
335 createdAt: { 335 createdAt: {
336 [ Op.lt ]: expiredDate 336 [Op.lt]: expiredDate
337 } 337 }
338 } 338 }
339 } 339 }
@@ -392,7 +392,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
392 where: { 392 where: {
393 actorId: actor.id, 393 actorId: actor.id,
394 expiresOn: { 394 expiresOn: {
395 [ Op.lt ]: new Date() 395 [Op.lt]: new Date()
396 } 396 }
397 } 397 }
398 } 398 }
@@ -409,8 +409,8 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
409 [Op.ne]: actor.id 409 [Op.ne]: actor.id
410 }, 410 },
411 expiresOn: { 411 expiresOn: {
412 [ Op.lt ]: new Date(), 412 [Op.lt]: new Date(),
413 [ Op.ne ]: null 413 [Op.ne]: null
414 } 414 }
415 } 415 }
416 } 416 }
@@ -464,15 +464,15 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
464 } 464 }
465 465
466 static listForApi (options: { 466 static listForApi (options: {
467 start: number, 467 start: number
468 count: number, 468 count: number
469 sort: string, 469 sort: string
470 target: VideoRedundanciesTarget, 470 target: VideoRedundanciesTarget
471 strategy?: string 471 strategy?: string
472 }) { 472 }) {
473 const { start, count, sort, target, strategy } = options 473 const { start, count, sort, target, strategy } = options
474 let redundancyWhere: WhereOptions = {} 474 const redundancyWhere: WhereOptions = {}
475 let videosWhere: WhereOptions = {} 475 const videosWhere: WhereOptions = {}
476 let redundancySqlSuffix = '' 476 let redundancySqlSuffix = ''
477 477
478 if (target === 'my-videos') { 478 if (target === 'my-videos') {
@@ -490,10 +490,10 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
490 const videoFilterWhere = { 490 const videoFilterWhere = {
491 [Op.and]: [ 491 [Op.and]: [
492 { 492 {
493 [ Op.or ]: [ 493 [Op.or]: [
494 { 494 {
495 id: { 495 id: {
496 [ Op.in ]: literal( 496 [Op.in]: literal(
497 '(' + 497 '(' +
498 'SELECT "videoId" FROM "videoFile" ' + 498 'SELECT "videoId" FROM "videoFile" ' +
499 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoFileId" = "videoFile".id' + 499 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoFileId" = "videoFile".id' +
@@ -504,7 +504,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
504 }, 504 },
505 { 505 {
506 id: { 506 id: {
507 [ Op.in ]: literal( 507 [Op.in]: literal(
508 '(' + 508 '(' +
509 'select "videoId" FROM "videoStreamingPlaylist" ' + 509 'select "videoId" FROM "videoStreamingPlaylist" ' +
510 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoStreamingPlaylistId" = "videoStreamingPlaylist".id' + 510 'INNER JOIN "videoRedundancy" ON "videoRedundancy"."videoStreamingPlaylistId" = "videoStreamingPlaylist".id' +
@@ -592,16 +592,16 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
592 } 592 }
593 593
594 return VideoRedundancyModel.findOne(query) 594 return VideoRedundancyModel.findOne(query)
595 .then((r: any) => ({ 595 .then((r: any) => ({
596 totalUsed: parseAggregateResult(r.totalUsed), 596 totalUsed: parseAggregateResult(r.totalUsed),
597 totalVideos: r.totalVideos, 597 totalVideos: r.totalVideos,
598 totalVideoFiles: r.totalVideoFiles 598 totalVideoFiles: r.totalVideoFiles
599 })) 599 }))
600 } 600 }
601 601
602 static toFormattedJSONStatic (video: MVideoForRedundancyAPI): VideoRedundancy { 602 static toFormattedJSONStatic (video: MVideoForRedundancyAPI): VideoRedundancy {
603 let filesRedundancies: FileRedundancyInformation[] = [] 603 const filesRedundancies: FileRedundancyInformation[] = []
604 let streamingPlaylistsRedundancies: StreamingPlaylistRedundancyInformation[] = [] 604 const streamingPlaylistsRedundancies: StreamingPlaylistRedundancyInformation[] = []
605 605
606 for (const file of video.VideoFiles) { 606 for (const file of video.VideoFiles) {
607 for (const redundancy of file.RedundancyVideos) { 607 for (const redundancy of file.RedundancyVideos) {
@@ -678,7 +678,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
678 expires: this.expiresOn ? this.expiresOn.toISOString() : null, 678 expires: this.expiresOn ? this.expiresOn.toISOString() : null,
679 url: { 679 url: {
680 type: 'Link', 680 type: 'Link',
681 mediaType: MIMETYPES.VIDEO.EXT_MIMETYPE[ this.VideoFile.extname ] as any, 681 mediaType: MIMETYPES.VIDEO.EXT_MIMETYPE[this.VideoFile.extname] as any,
682 href: this.fileUrl, 682 href: this.fileUrl,
683 height: this.VideoFile.resolution, 683 height: this.VideoFile.resolution,
684 size: this.VideoFile.size, 684 size: this.VideoFile.size,
@@ -693,7 +693,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
693 693
694 const notIn = literal( 694 const notIn = literal(
695 '(' + 695 '(' +
696 `SELECT "videoFileId" FROM "videoRedundancy" WHERE "actorId" = ${actor.id} AND "videoFileId" IS NOT NULL` + 696 `SELECT "videoFileId" FROM "videoRedundancy" WHERE "actorId" = ${actor.id} AND "videoFileId" IS NOT NULL` +
697 ')' 697 ')'
698 ) 698 )
699 699
@@ -703,7 +703,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
703 required: true, 703 required: true,
704 where: { 704 where: {
705 id: { 705 id: {
706 [ Op.notIn ]: notIn 706 [Op.notIn]: notIn
707 } 707 }
708 } 708 }
709 } 709 }