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

View file

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