diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 2bfa704ec..720bfd829 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -129,6 +129,7 @@ import { VideoShareModel } from './video-share' | |||
129 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 129 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' |
130 | import { VideoTagModel } from './video-tag' | 130 | import { VideoTagModel } from './video-tag' |
131 | import { VideoViewModel } from './video-view' | 131 | import { VideoViewModel } from './video-view' |
132 | import { UserModel } from '../account/user' | ||
132 | 133 | ||
133 | export enum ScopeNames { | 134 | export enum ScopeNames { |
134 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', | 135 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', |
@@ -1198,6 +1199,39 @@ export class VideoModel extends Model { | |||
1198 | return VideoModel.count(options) | 1199 | return VideoModel.count(options) |
1199 | } | 1200 | } |
1200 | 1201 | ||
1202 | static countVideosUploadedByUserSince (userId: number, since: Date) { | ||
1203 | const options = { | ||
1204 | include: [ | ||
1205 | { | ||
1206 | model: VideoChannelModel.unscoped(), | ||
1207 | required: true, | ||
1208 | include: [ | ||
1209 | { | ||
1210 | model: AccountModel.unscoped(), | ||
1211 | required: true, | ||
1212 | include: [ | ||
1213 | { | ||
1214 | model: UserModel.unscoped(), | ||
1215 | required: true, | ||
1216 | where: { | ||
1217 | id: userId | ||
1218 | } | ||
1219 | } | ||
1220 | ] | ||
1221 | } | ||
1222 | ] | ||
1223 | } | ||
1224 | ], | ||
1225 | where: { | ||
1226 | createdAt: { | ||
1227 | [Op.gte]: since | ||
1228 | } | ||
1229 | } | ||
1230 | } | ||
1231 | |||
1232 | return VideoModel.unscoped().count(options) | ||
1233 | } | ||
1234 | |||
1201 | static countLivesOfAccount (accountId: number) { | 1235 | static countLivesOfAccount (accountId: number) { |
1202 | const options = { | 1236 | const options = { |
1203 | where: { | 1237 | where: { |