@AllowNull(true)
@Default(null)
@Column
- privacy: VideoPrivacy
+ privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED
@CreatedAt
createdAt: Date
})
Video: VideoModel
+ static areVideosToUpdate () {
+ const query = {
+ logging: false,
+ attributes: [ 'id' ],
+ where: {
+ updateAt: {
+ [Sequelize.Op.lte]: new Date()
+ }
+ }
+ }
+
+ return ScheduleVideoUpdateModel.findOne(query)
+ .then(res => !!res)
+ }
+
static listVideosToUpdate (t: Transaction) {
const query = {
where: {
model: VideoModel.scope(
[
VideoScopeNames.WITH_FILES,
- VideoScopeNames.WITH_ACCOUNT_DETAILS
+ VideoScopeNames.WITH_ACCOUNT_DETAILS,
+ VideoScopeNames.WITH_BLACKLISTED
]
)
}
return ScheduleVideoUpdateModel.findAll(query)
}
+ static deleteByVideoId (videoId: number, t: Transaction) {
+ const query = {
+ where: {
+ videoId
+ },
+ transaction: t
+ }
+
+ return ScheduleVideoUpdateModel.destroy(query)
+ }
+
+ toFormattedJSON () {
+ return {
+ updateAt: this.updateAt,
+ privacy: this.privacy || undefined
+ }
+ }
}