aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 4147b3d62..8bad2a01e 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1402,7 +1402,21 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1402 }) 1402 })
1403 } 1403 }
1404 1404
1405 static updateRatesOf (videoId: number, type: VideoRateType, t: Transaction) { 1405 static updateRatesOf (videoId: number, type: VideoRateType, count: number, t: Transaction) {
1406 const field = type === 'like'
1407 ? 'likes'
1408 : 'dislikes'
1409
1410 const rawQuery = `UPDATE "video" SET "${field}" = :count WHERE "video"."id" = :videoId`
1411
1412 return AccountVideoRateModel.sequelize.query(rawQuery, {
1413 transaction: t,
1414 replacements: { videoId, rateType: type, count },
1415 type: QueryTypes.UPDATE
1416 })
1417 }
1418
1419 static syncLocalRates (videoId: number, type: VideoRateType, t: Transaction) {
1406 const field = type === 'like' 1420 const field = type === 'like'
1407 ? 'likes' 1421 ? 'likes'
1408 : 'dislikes' 1422 : 'dislikes'