+ static countLocalLives () {
+ const options = {
+ where: {
+ remote: false,
+ isLive: true,
+ state: {
+ [Op.ne]: VideoState.LIVE_ENDED
+ }
+ }
+ }
+
+ return VideoModel.count(options)
+ }
+
+ static countVideosUploadedByUserSince (userId: number, since: Date) {
+ const options = {
+ include: [
+ {
+ model: VideoChannelModel.unscoped(),
+ required: true,
+ include: [
+ {
+ model: AccountModel.unscoped(),
+ required: true,
+ include: [
+ {
+ model: UserModel.unscoped(),
+ required: true,
+ where: {
+ id: userId
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ where: {
+ createdAt: {
+ [Op.gte]: since
+ }
+ }
+ }
+
+ return VideoModel.unscoped().count(options)
+ }
+
+ static countLivesOfAccount (accountId: number) {
+ const options = {
+ where: {
+ remote: false,
+ isLive: true,
+ state: {
+ [Op.ne]: VideoState.LIVE_ENDED
+ }
+ },
+ include: [
+ {
+ required: true,
+ model: VideoChannelModel.unscoped(),
+ where: {
+ accountId
+ }
+ }
+ ]
+ }
+
+ return VideoModel.count(options)
+ }
+
+ static load (id: number | string, t?: Transaction): Promise<MVideoThumbnail> {