Fixes superlatives

This commit is contained in:
Mouse Reeve
2022-01-06 09:22:10 -08:00
parent 705f6d36a6
commit 840746754d
3 changed files with 8 additions and 8 deletions

View File

@ -30,16 +30,16 @@ def about(request):
books = models.Edition.objects.exclude(cover__exact="")
data["top_rated"] = books.annotate(
rating=Avg("review__rating")
).order_by("rating").first()
rating=Avg("review__rating", filter=Q(review__user__local=True))
).filter(rating__gt=0).order_by("-rating").first()
data["controversial"] = books.annotate(
deviation=StdDev("review__rating")
).order_by("deviation").first()
).filter(deviation__gt=0).order_by("-deviation").first()
data["wanted"] = books.annotate(
shelf_count=Count("shelves", filter=Q(shelves__identifier="to-read"))
).order_by("shelf_count").first()
).order_by("-shelf_count").first()
return TemplateResponse(request, "about/about.html", data)