diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 11:13:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 11:16:14 +0200 |
commit | ae9bbed46dbc8d9870c9feb66bbada484c1c7582 (patch) | |
tree | 69a04af65274f9f39cb439384ad58b1fc1058ba0 /server/models/video/video-file.ts | |
parent | 14aed608f540b587b3ab2529d06690815214d232 (diff) | |
download | PeerTube-ae9bbed46dbc8d9870c9feb66bbada484c1c7582.tar.gz PeerTube-ae9bbed46dbc8d9870c9feb66bbada484c1c7582.tar.zst PeerTube-ae9bbed46dbc8d9870c9feb66bbada484c1c7582.zip |
Update P2P media loader peer version
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: [ |