Use False instead of None for test values

This commit is contained in:
Mouse Reeve 2022-01-17 12:45:32 -08:00
parent 1e4aee8276
commit 02dd1e9443
2 changed files with 5 additions and 4 deletions

View file

@ -376,7 +376,8 @@ class Review(BookStatus):
def save(self, *args, **kwargs):
"""clear rating caches"""
cache.delete(f"book-rating-{self.book.parent_work.id}-*")
if self.book.parent_work:
cache.delete(f"book-rating-{self.book.parent_work.id}-*")
super().save(*args, **kwargs)

View file

@ -17,7 +17,7 @@ def get_rating(book, user):
f"book-rating-{book.parent_work.id}-{user.id}",
lambda u, b: models.Review.privacy_filter(u)
.filter(book__parent_work__editions=b)
.aggregate(Avg("rating"))["rating__avg"],
.aggregate(Avg("rating"))["rating__avg"] or 0,
user,
book,
timeout=15552000,
@ -144,7 +144,7 @@ def active_shelf(context, book):
models.ShelfBook.objects.filter(
shelf__user=u,
book__parent_work__editions=b,
).first()
).first() or False
),
user,
book,
@ -162,7 +162,7 @@ def latest_read_through(book, user):
lambda u, b: (
models.ReadThrough.objects.filter(user=u, book=b, is_active=True)
.order_by("-start_date")
.first()
.first() or False
),
user,
book,