aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-19 10:26:58 +0100
committerChocobozzz <me@florianbigard.com>2021-02-19 10:26:58 +0100
commit285981f4dd1bdeaac32cb3f99be55edac9ef3f78 (patch)
tree0d6580831ac0e57b4a10a4aff7472852ab804e92
parent9d6b9d10ef8cbef39e89bc709285abffb0d8caa1 (diff)
downloadPeerTube-285981f4dd1bdeaac32cb3f99be55edac9ef3f78.tar.gz
PeerTube-285981f4dd1bdeaac32cb3f99be55edac9ef3f78.tar.zst
PeerTube-285981f4dd1bdeaac32cb3f99be55edac9ef3f78.zip
Optimize rate endpoint
-rw-r--r--server/controllers/api/videos/rate.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 520932c63..84f42633e 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -37,6 +37,9 @@ async function rateVideo (req: express.Request, res: express.Response) {
37 const accountInstance = await AccountModel.load(userAccount.id, t) 37 const accountInstance = await AccountModel.load(userAccount.id, t)
38 const previousRate = await AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t) 38 const previousRate = await AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t)
39 39
40 // Same rate, nothing do to
41 if (rateType === 'none' && !previousRate || previousRate?.type === rateType) return
42
40 let likesToIncrement = 0 43 let likesToIncrement = 0
41 let dislikesToIncrement = 0 44 let dislikesToIncrement = 0
42 45