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'
5 import { MScheduleVideoUpdateFormattable } from '@server/typings/models'
8 tableName: 'scheduleVideoUpdate',
11 fields: [ 'videoId' ],
15 fields: [ 'updateAt' ]
19 export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> {
29 privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED
37 @ForeignKey(() => VideoModel)
41 @BelongsTo(() => VideoModel, {
49 static areVideosToUpdate () {
60 return ScheduleVideoUpdateModel.findOne(query)
64 static listVideosToUpdate (t: Transaction) {
73 model: VideoModel.scope(
75 VideoScopeNames.WITH_FILES,
76 VideoScopeNames.WITH_ACCOUNT_DETAILS,
77 VideoScopeNames.WITH_BLACKLISTED,
78 VideoScopeNames.WITH_THUMBNAILS
86 return ScheduleVideoUpdateModel.findAll(query)
89 static deleteByVideoId (videoId: number, t: Transaction) {
97 return ScheduleVideoUpdateModel.destroy(query)
100 toFormattedJSON (this: MScheduleVideoUpdateFormattable) {
102 updateAt: this.updateAt,
103 privacy: this.privacy || undefined