diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account-video-rate.ts | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 7303651eb..5c7d9cfc0 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts | |||
@@ -12,7 +12,7 @@ import { AttributesOnly } from '@shared/typescript-utils' | |||
12 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 12 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
13 | import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' | 13 | import { CONSTRAINTS_FIELDS, VIDEO_RATE_TYPES } from '../../initializers/constants' |
14 | import { ActorModel } from '../actor/actor' | 14 | import { ActorModel } from '../actor/actor' |
15 | import { buildLocalAccountIdsIn, getSort, throwIfNotValid } from '../utils' | 15 | import { getSort, throwIfNotValid } from '../utils' |
16 | import { VideoModel } from '../video/video' | 16 | import { VideoModel } from '../video/video' |
17 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel' | 17 | import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel' |
18 | import { AccountModel } from './account' | 18 | import { AccountModel } from './account' |
@@ -249,28 +249,6 @@ export class AccountVideoRateModel extends Model<Partial<AttributesOnly<AccountV | |||
249 | ]).then(([ total, data ]) => ({ total, data })) | 249 | ]).then(([ total, data ]) => ({ total, data })) |
250 | } | 250 | } |
251 | 251 | ||
252 | static cleanOldRatesOf (videoId: number, type: VideoRateType, beforeUpdatedAt: Date) { | ||
253 | return AccountVideoRateModel.sequelize.transaction(async t => { | ||
254 | const query = { | ||
255 | where: { | ||
256 | updatedAt: { | ||
257 | [Op.lt]: beforeUpdatedAt | ||
258 | }, | ||
259 | videoId, | ||
260 | type, | ||
261 | accountId: { | ||
262 | [Op.notIn]: buildLocalAccountIdsIn() | ||
263 | } | ||
264 | }, | ||
265 | transaction: t | ||
266 | } | ||
267 | |||
268 | await AccountVideoRateModel.destroy(query) | ||
269 | |||
270 | return VideoModel.updateRatesOf(videoId, type, t) | ||
271 | }) | ||
272 | } | ||
273 | |||
274 | toFormattedJSON (this: MAccountVideoRateFormattable): AccountVideoRate { | 252 | toFormattedJSON (this: MAccountVideoRateFormattable): AccountVideoRate { |
275 | return { | 253 | return { |
276 | video: this.Video.toFormattedJSON(), | 254 | video: this.Video.toFormattedJSON(), |