diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-10 08:07:21 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-10 08:07:21 +0100 |
commit | 0b84383d488facc321b100f3280a872ee53e888b (patch) | |
tree | 8d6676ca07851adb35311597ee2b1bb6978f6c00 /server/models | |
parent | c1961762b31567057e32eb7432a6995a4a81075c (diff) | |
download | PeerTube-0b84383d488facc321b100f3280a872ee53e888b.tar.gz PeerTube-0b84383d488facc321b100f3280a872ee53e888b.tar.zst PeerTube-0b84383d488facc321b100f3280a872ee53e888b.zip |
Fix stat file size with HLS
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video-file.ts | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index a130317f6..d48c9f5d4 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -269,10 +269,11 @@ export class VideoFileModel extends Model<VideoFileModel> { | |||
269 | } | 269 | } |
270 | 270 | ||
271 | static getStats () { | 271 | static getStats () { |
272 | const query: FindOptions = { | 272 | const webtorrentFilesQuery: FindOptions = { |
273 | include: [ | 273 | include: [ |
274 | { | 274 | { |
275 | attributes: [], | 275 | attributes: [], |
276 | required: true, | ||
276 | model: VideoModel.unscoped(), | 277 | model: VideoModel.unscoped(), |
277 | where: { | 278 | where: { |
278 | remote: false | 279 | remote: false |
@@ -281,10 +282,32 @@ export class VideoFileModel extends Model<VideoFileModel> { | |||
281 | ] | 282 | ] |
282 | } | 283 | } |
283 | 284 | ||
284 | return VideoFileModel.aggregate('size', 'SUM', query) | 285 | const hlsFilesQuery: FindOptions = { |
285 | .then(result => ({ | 286 | include: [ |
286 | totalLocalVideoFilesSize: parseAggregateResult(result) | 287 | { |
287 | })) | 288 | attributes: [], |
289 | required: true, | ||
290 | model: VideoStreamingPlaylistModel.unscoped(), | ||
291 | include: [ | ||
292 | { | ||
293 | attributes: [], | ||
294 | model: VideoModel.unscoped(), | ||
295 | required: true, | ||
296 | where: { | ||
297 | remote: false | ||
298 | } | ||
299 | } | ||
300 | ] | ||
301 | } | ||
302 | ] | ||
303 | } | ||
304 | |||
305 | return Promise.all([ | ||
306 | VideoFileModel.aggregate('size', 'SUM', webtorrentFilesQuery), | ||
307 | VideoFileModel.aggregate('size', 'SUM', hlsFilesQuery) | ||
308 | ]).then(([ webtorrentResult, hlsResult ]) => ({ | ||
309 | totalLocalVideoFilesSize: parseAggregateResult(webtorrentResult) + parseAggregateResult(hlsResult) | ||
310 | })) | ||
288 | } | 311 | } |
289 | 312 | ||
290 | // Redefine upsert because sequelize does not use an appropriate where clause in the update query with 2 unique indexes | 313 | // Redefine upsert because sequelize does not use an appropriate where clause in the update query with 2 unique indexes |