1 import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { ScopeNames as VideoScopeNames, VideoModel } from './video'
3 import { VideoPrivacy } from '../../../shared/models/videos'
4 import { Op, 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 () {
59 return ScheduleVideoUpdateModel.findOne(query)
63 static listVideosToUpdate (t: Transaction) {
72 model: VideoModel.scope(
74 VideoScopeNames.WITH_FILES,
75 VideoScopeNames.WITH_ACCOUNT_DETAILS,
76 VideoScopeNames.WITH_BLACKLISTED,
77 VideoScopeNames.WITH_THUMBNAILS
85 return ScheduleVideoUpdateModel.findAll(query)
88 static deleteByVideoId (videoId: number, t: Transaction) {
96 return ScheduleVideoUpdateModel.destroy(query)
101 updateAt: this.updateAt,
102 privacy: this.privacy || undefined