From 44b9c0ba31c4a97e3d874f33226ad935c3a90dd5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Jan 2019 09:45:54 +0100 Subject: Add totalLocalVideoFilesSize in stats --- server/models/video/video-file.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'server/models/video') diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 0fd868cd6..1f1b76c1e 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -120,6 +120,26 @@ export class VideoFileModel extends Model { return VideoFileModel.findById(id, options) } + static async getStats () { + let totalLocalVideoFilesSize = await VideoFileModel.sum('size', { + include: [ + { + attributes: [], + model: VideoModel.unscoped(), + where: { + remote: false + } + } + ] + } as any) + // Sequelize could return null... + if (!totalLocalVideoFilesSize) totalLocalVideoFilesSize = 0 + + return { + totalLocalVideoFilesSize + } + } + hasSameUniqueKeysThan (other: VideoFileModel) { return this.fps === other.fps && this.resolution === other.resolution && -- cgit v1.2.3