Optimize rate endpoint

pull/3759/head
Chocobozzz 2021-02-19 10:26:58 +01:00
parent 9d6b9d10ef
commit 285981f4dd
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 0 deletions

View File

@ -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