aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/schedule-video-update.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/schedule-video-update.ts')
-rw-r--r--server/models/video/schedule-video-update.ts29
1 files changed, 8 insertions, 21 deletions
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts
index 22b08e91a..d462c20c7 100644
--- a/server/models/video/schedule-video-update.ts
+++ b/server/models/video/schedule-video-update.ts
@@ -1,8 +1,9 @@
1import { Op, Transaction } from 'sequelize'
1import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' 2import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2import { ScopeNames as VideoScopeNames, VideoModel } from './video' 3import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdate } from '@server/types/models'
4import { AttributesOnly } from '@shared/core-utils'
3import { VideoPrivacy } from '../../../shared/models/videos' 5import { VideoPrivacy } from '../../../shared/models/videos'
4import { Op, Transaction } from 'sequelize' 6import { VideoModel } from './video'
5import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdateVideoAll } from '@server/types/models'
6 7
7@Table({ 8@Table({
8 tableName: 'scheduleVideoUpdate', 9 tableName: 'scheduleVideoUpdate',
@@ -16,7 +17,7 @@ import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdateVideoAll } from '@
16 } 17 }
17 ] 18 ]
18}) 19})
19export class ScheduleVideoUpdateModel extends Model { 20export class ScheduleVideoUpdateModel extends Model<Partial<AttributesOnly<ScheduleVideoUpdateModel>>> {
20 21
21 @AllowNull(false) 22 @AllowNull(false)
22 @Default(null) 23 @Default(null)
@@ -61,31 +62,17 @@ export class ScheduleVideoUpdateModel extends Model {
61 .then(res => !!res) 62 .then(res => !!res)
62 } 63 }
63 64
64 static listVideosToUpdate (t: Transaction) { 65 static listVideosToUpdate (transaction?: Transaction) {
65 const query = { 66 const query = {
66 where: { 67 where: {
67 updateAt: { 68 updateAt: {
68 [Op.lte]: new Date() 69 [Op.lte]: new Date()
69 } 70 }
70 }, 71 },
71 include: [ 72 transaction
72 {
73 model: VideoModel.scope(
74 [
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
81 ]
82 )
83 }
84 ],
85 transaction: t
86 } 73 }
87 74
88 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdateVideoAll>(query) 75 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdate>(query)
89 } 76 }
90 77
91 static deleteByVideoId (videoId: number, t: Transaction) { 78 static deleteByVideoId (videoId: number, t: Transaction) {