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, MScheduleVideoUpdateVideoAll } 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 | VideoPrivacy.INTERNAL
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_WEBTORRENT_FILES,
76 VideoScopeNames.WITH_STREAMING_PLAYLISTS,
77 VideoScopeNames.WITH_ACCOUNT_DETAILS,
78 VideoScopeNames.WITH_BLACKLISTED,
79 VideoScopeNames.WITH_THUMBNAILS,
80 VideoScopeNames.WITH_TAGS
88 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdateVideoAll>(query)
91 static deleteByVideoId (videoId: number, t: Transaction) {
99 return ScheduleVideoUpdateModel.destroy(query)
102 toFormattedJSON (this: MScheduleVideoUpdateFormattable) {
104 updateAt: this.updateAt,
105 privacy: this.privacy || undefined