aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts34
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'
129import { VideoStreamingPlaylistModel } from './video-streaming-playlist' 129import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
130import { VideoTagModel } from './video-tag' 130import { VideoTagModel } from './video-tag'
131import { VideoViewModel } from './video-view' 131import { VideoViewModel } from './video-view'
132import { UserModel } from '../account/user'
132 133
133export enum ScopeNames { 134export 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: {