diff options
Diffstat (limited to 'server/models/video/video-file.ts')
-rw-r--r-- | server/models/video/video-file.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index b861b0704..c14d96bc5 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts | |||
@@ -23,6 +23,7 @@ import { throwIfNotValid } from '../utils' | |||
23 | import { VideoModel } from './video' | 23 | import { VideoModel } from './video' |
24 | import * as Sequelize from 'sequelize' | 24 | import * as Sequelize from 'sequelize' |
25 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' | 25 | import { VideoRedundancyModel } from '../redundancy/video-redundancy' |
26 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | ||
26 | 27 | ||
27 | @Table({ | 28 | @Table({ |
28 | tableName: 'videoFile', | 29 | tableName: 'videoFile', |
@@ -120,6 +121,29 @@ export class VideoFileModel extends Model<VideoFileModel> { | |||
120 | return VideoFileModel.findByPk(id, options) | 121 | return VideoFileModel.findByPk(id, options) |
121 | } | 122 | } |
122 | 123 | ||
124 | static listByStreamingPlaylist (streamingPlaylistId: number, transaction: Sequelize.Transaction) { | ||
125 | const query = { | ||
126 | include: [ | ||
127 | { | ||
128 | model: VideoModel.unscoped(), | ||
129 | required: true, | ||
130 | include: [ | ||
131 | { | ||
132 | model: VideoStreamingPlaylistModel.unscoped(), | ||
133 | required: true, | ||
134 | where: { | ||
135 | id: streamingPlaylistId | ||
136 | } | ||
137 | } | ||
138 | ] | ||
139 | } | ||
140 | ], | ||
141 | transaction | ||
142 | } | ||
143 | |||
144 | return VideoFileModel.findAll(query) | ||
145 | } | ||
146 | |||
123 | static async getStats () { | 147 | static async getStats () { |
124 | let totalLocalVideoFilesSize = await VideoFileModel.sum('size', { | 148 | let totalLocalVideoFilesSize = await VideoFileModel.sum('size', { |
125 | include: [ | 149 | include: [ |