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.ts38
1 files changed, 30 insertions, 8 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index eb2222256..8621a5c6c 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -325,23 +325,45 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
325 325
326 static async getTotalDuplicated (strategy: VideoRedundancyStrategy) { 326 static async getTotalDuplicated (strategy: VideoRedundancyStrategy) {
327 const actor = await getServerActor() 327 const actor = await getServerActor()
328 const redundancyInclude = {
329 attributes: [],
330 model: VideoRedundancyModel,
331 required: true,
332 where: {
333 actorId: actor.id,
334 strategy
335 }
336 }
328 337
329 const query: FindOptions = { 338 const queryFiles: FindOptions = {
339 include: [ redundancyInclude ]
340 }
341
342 const queryStreamingPlaylists: FindOptions = {
330 include: [ 343 include: [
331 { 344 {
332 attributes: [], 345 attributes: [],
333 model: VideoRedundancyModel, 346 model: VideoModel.unscoped(),
334 required: true, 347 required: true,
335 where: { 348 include: [
336 actorId: actor.id, 349 {
337 strategy 350 attributes: [],
338 } 351 model: VideoStreamingPlaylistModel.unscoped(),
352 include: [
353 redundancyInclude
354 ]
355 }
356 ]
339 } 357 }
340 ] 358 ]
341 } 359 }
342 360
343 return VideoFileModel.aggregate('size', 'SUM', query) 361 return Promise.all([
344 .then(result => parseAggregateResult(result)) 362 VideoFileModel.aggregate('size', 'SUM', queryFiles),
363 VideoFileModel.aggregate('size', 'SUM', queryStreamingPlaylists)
364 ]).then(([ r1, r2 ]) => {
365 return parseAggregateResult(r1) + parseAggregateResult(r2)
366 })
345 } 367 }
346 368
347 static async listLocalExpired () { 369 static async listLocalExpired () {