1 import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Sequelize, Table, UpdatedAt } from 'sequelize-typescript'
2 import { ScopeNames as VideoScopeNames, VideoModel } from './video'
3 import { VideoPrivacy } from '../../../shared/models/videos'
4 import { Transaction } from 'sequelize'
7 tableName: 'scheduleVideoUpdate',
10 fields: [ 'videoId' ],
14 fields: [ 'updateAt' ]
18 export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> {
28 privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED
36 @ForeignKey(() => VideoModel)
40 @BelongsTo(() => VideoModel, {
48 static areVideosToUpdate () {
54 [Sequelize.Op.lte]: new Date()
59 return ScheduleVideoUpdateModel.findOne(query)
63 static listVideosToUpdate (t: Transaction) {
67 [Sequelize.Op.lte]: new Date()
72 model: VideoModel.scope(
74 VideoScopeNames.WITH_FILES,
75 VideoScopeNames.WITH_ACCOUNT_DETAILS,
76 VideoScopeNames.WITH_BLACKLISTED
84 return ScheduleVideoUpdateModel.findAll(query)
87 static deleteByVideoId (videoId: number, t: Transaction) {
95 return ScheduleVideoUpdateModel.destroy(query)
100 updateAt: this.updateAt,
101 privacy: this.privacy || undefined