diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-15 09:45:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-15 09:45:54 +0100 |
commit | 44b9c0ba31c4a97e3d874f33226ad935c3a90dd5 (patch) | |
tree | cb0b5e55ed3f8bafa439f233f43aca5c71a44515 /server/models/video/video-file.ts | |
parent | 3195cd1c118f5e020ab7e635d5a3dcdad2108b1a (diff) | |
download | PeerTube-44b9c0ba31c4a97e3d874f33226ad935c3a90dd5.tar.gz PeerTube-44b9c0ba31c4a97e3d874f33226ad935c3a90dd5.tar.zst PeerTube-44b9c0ba31c4a97e3d874f33226ad935c3a90dd5.zip |
Add totalLocalVideoFilesSize in stats
Diffstat (limited to 'server/models/video/video-file.ts')
-rw-r--r-- | server/models/video/video-file.ts | 20 |
1 files changed, 20 insertions, 0 deletions
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<VideoFileModel> { | |||
120 | return VideoFileModel.findById(id, options) | 120 | return VideoFileModel.findById(id, options) |
121 | } | 121 | } |
122 | 122 | ||
123 | static async getStats () { | ||
124 | let totalLocalVideoFilesSize = await VideoFileModel.sum('size', { | ||
125 | include: [ | ||
126 | { | ||
127 | attributes: [], | ||
128 | model: VideoModel.unscoped(), | ||
129 | where: { | ||
130 | remote: false | ||
131 | } | ||
132 | } | ||
133 | ] | ||
134 | } as any) | ||
135 | // Sequelize could return null... | ||
136 | if (!totalLocalVideoFilesSize) totalLocalVideoFilesSize = 0 | ||
137 | |||
138 | return { | ||
139 | totalLocalVideoFilesSize | ||
140 | } | ||
141 | } | ||
142 | |||
123 | hasSameUniqueKeysThan (other: VideoFileModel) { | 143 | hasSameUniqueKeysThan (other: VideoFileModel) { |
124 | return this.fps === other.fps && | 144 | return this.fps === other.fps && |
125 | this.resolution === other.resolution && | 145 | this.resolution === other.resolution && |