From 285981f4dd1bdeaac32cb3f99be55edac9ef3f78 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Feb 2021 10:26:58 +0100 Subject: Optimize rate endpoint --- server/controllers/api/videos/rate.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'server') 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) { const accountInstance = await AccountModel.load(userAccount.id, t) const previousRate = await AccountVideoRateModel.load(accountInstance.id, videoInstance.id, t) + // Same rate, nothing do to + if (rateType === 'none' && !previousRate || previousRate?.type === rateType) return + let likesToIncrement = 0 let dislikesToIncrement = 0 -- cgit v1.2.3