aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-11 14:33:16 +0200
committerChocobozzz <me@florianbigard.com>2021-06-11 14:33:34 +0200
commitfd6a74a83594bfb59e28bf9cae71a39884ebcc2f (patch)
treee1ba2f28ac76c0a3af54448c401063c9ad2702e4 /server/models/video
parent20a206c3d12ad285c31411cd506cede791958322 (diff)
downloadPeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.tar.gz
PeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.tar.zst
PeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.zip
Refactor schedule update
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/schedule-video-update.ts24
1 files changed, 5 insertions, 19 deletions
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts
index b0952c431..d462c20c7 100644
--- a/server/models/video/schedule-video-update.ts
+++ b/server/models/video/schedule-video-update.ts
@@ -1,9 +1,9 @@
1import { Op, Transaction } from 'sequelize' 1import { Op, Transaction } from 'sequelize'
2import { 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'
3import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdateVideoAll } from '@server/types/models' 3import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdate } from '@server/types/models'
4import { AttributesOnly } from '@shared/core-utils' 4import { AttributesOnly } from '@shared/core-utils'
5import { VideoPrivacy } from '../../../shared/models/videos' 5import { VideoPrivacy } from '../../../shared/models/videos'
6import { ScopeNames as VideoScopeNames, VideoModel } from './video' 6import { VideoModel } from './video'
7 7
8@Table({ 8@Table({
9 tableName: 'scheduleVideoUpdate', 9 tableName: 'scheduleVideoUpdate',
@@ -62,31 +62,17 @@ export class ScheduleVideoUpdateModel extends Model<Partial<AttributesOnly<Sched
62 .then(res => !!res) 62 .then(res => !!res)
63 } 63 }
64 64
65 static listVideosToUpdate (t: Transaction) { 65 static listVideosToUpdate (transaction?: Transaction) {
66 const query = { 66 const query = {
67 where: { 67 where: {
68 updateAt: { 68 updateAt: {
69 [Op.lte]: new Date() 69 [Op.lte]: new Date()
70 } 70 }
71 }, 71 },
72 include: [ 72 transaction
73 {
74 model: VideoModel.scope(
75 [
76 VideoScopeNames.WITH_WEBTORRENT_FILES,
77 VideoScopeNames.WITH_STREAMING_PLAYLISTS,
78 VideoScopeNames.WITH_ACCOUNT_DETAILS,
79 VideoScopeNames.WITH_BLACKLISTED,
80 VideoScopeNames.WITH_THUMBNAILS,
81 VideoScopeNames.WITH_TAGS
82 ]
83 )
84 }
85 ],
86 transaction: t
87 } 73 }
88 74
89 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdateVideoAll>(query) 75 return ScheduleVideoUpdateModel.findAll<MScheduleVideoUpdate>(query)
90 } 76 }
91 77
92 static deleteByVideoId (videoId: number, t: Transaction) { 78 static deleteByVideoId (videoId: number, t: Transaction) {