diff options
Diffstat (limited to 'server/models/video/schedule-video-update.ts')
-rw-r--r-- | server/models/video/schedule-video-update.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts index d4e37beb5..3cf5f6c99 100644 --- a/server/models/video/schedule-video-update.ts +++ b/server/models/video/schedule-video-update.ts | |||
@@ -25,7 +25,7 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
25 | @AllowNull(true) | 25 | @AllowNull(true) |
26 | @Default(null) | 26 | @Default(null) |
27 | @Column | 27 | @Column |
28 | privacy: VideoPrivacy | 28 | privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED |
29 | 29 | ||
30 | @CreatedAt | 30 | @CreatedAt |
31 | createdAt: Date | 31 | createdAt: Date |
@@ -45,6 +45,21 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
45 | }) | 45 | }) |
46 | Video: VideoModel | 46 | Video: VideoModel |
47 | 47 | ||
48 | static areVideosToUpdate () { | ||
49 | const query = { | ||
50 | logging: false, | ||
51 | attributes: [ 'id' ], | ||
52 | where: { | ||
53 | updateAt: { | ||
54 | [Sequelize.Op.lte]: new Date() | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | return ScheduleVideoUpdateModel.findOne(query) | ||
60 | .then(res => !!res) | ||
61 | } | ||
62 | |||
48 | static listVideosToUpdate (t: Transaction) { | 63 | static listVideosToUpdate (t: Transaction) { |
49 | const query = { | 64 | const query = { |
50 | where: { | 65 | where: { |
@@ -68,4 +83,10 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
68 | return ScheduleVideoUpdateModel.findAll(query) | 83 | return ScheduleVideoUpdateModel.findAll(query) |
69 | } | 84 | } |
70 | 85 | ||
86 | toFormattedJSON () { | ||
87 | return { | ||
88 | updateAt: this.updateAt, | ||
89 | privacy: this.privacy || undefined | ||
90 | } | ||
91 | } | ||
71 | } | 92 | } |