diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:33:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:33:34 +0200 |
commit | fd6a74a83594bfb59e28bf9cae71a39884ebcc2f (patch) | |
tree | e1ba2f28ac76c0a3af54448c401063c9ad2702e4 /server/models | |
parent | 20a206c3d12ad285c31411cd506cede791958322 (diff) | |
download | PeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.tar.gz PeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.tar.zst PeerTube-fd6a74a83594bfb59e28bf9cae71a39884ebcc2f.zip |
Refactor schedule update
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/schedule-video-update.ts | 24 |
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 @@ | |||
1 | import { Op, Transaction } from 'sequelize' | 1 | import { Op, Transaction } from 'sequelize' |
2 | import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdateVideoAll } from '@server/types/models' | 3 | import { MScheduleVideoUpdateFormattable, MScheduleVideoUpdate } from '@server/types/models' |
4 | import { AttributesOnly } from '@shared/core-utils' | 4 | import { AttributesOnly } from '@shared/core-utils' |
5 | import { VideoPrivacy } from '../../../shared/models/videos' | 5 | import { VideoPrivacy } from '../../../shared/models/videos' |
6 | import { ScopeNames as VideoScopeNames, VideoModel } from './video' | 6 | import { 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) { |