Cache user-specific ratings
This commit is contained in:
@ -3,6 +3,7 @@ from dataclasses import MISSING
|
||||
import re
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.cache import cache
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models
|
||||
@ -373,6 +374,11 @@ class Review(BookStatus):
|
||||
activity_serializer = activitypub.Review
|
||||
pure_type = "Article"
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""clear rating caches"""
|
||||
cache.delete(f"book-rating-{self.book.parent_work.id}-*")
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class ReviewRating(Review):
|
||||
"""a subtype of review that only contains a rating"""
|
||||
|
Reference in New Issue
Block a user