mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-05 03:18:45 +00:00
Restore behaviour of cached review stats
This commit is contained in:
parent
16a41d4fb5
commit
aa71592a1e
1 changed files with 10 additions and 0 deletions
|
@ -269,8 +269,18 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
this.database.RatedReviews.Add(ratedReview);
|
||||
}
|
||||
|
||||
int oldThumb = ratedReview.Thumb;
|
||||
ratedReview.Thumb = Math.Max(Math.Min(1, rating), -1);
|
||||
|
||||
if (oldThumb != ratedReview.Thumb)
|
||||
{
|
||||
if (oldThumb == -1) review.ThumbsDown--;
|
||||
else if (oldThumb == 1) review.ThumbsUp--;
|
||||
|
||||
if (ratedReview.Thumb == -1) review.ThumbsDown++;
|
||||
else if (ratedReview.Thumb == 1) review.ThumbsUp++;
|
||||
}
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Ok();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue