aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-12 08:46:46 +0200
committerChocobozzz <me@florianbigard.com>2019-08-12 08:46:46 +0200
commit0b353d1d8a659140d10b8f7bff3f114698c1a715 (patch)
tree4d6cadfff782baa8ec253898a20849d05f584733 /server/models
parente2600d8b261994abbbeb1ff921edaefd267fc122 (diff)
downloadPeerTube-0b353d1d8a659140d10b8f7bff3f114698c1a715.tar.gz
PeerTube-0b353d1d8a659140d10b8f7bff3f114698c1a715.tar.zst
PeerTube-0b353d1d8a659140d10b8f7bff3f114698c1a715.zip
Fix redundancy exceeding the limit
Diffstat (limited to 'server/models')
-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 () {