aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-file.ts33
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