Use accurate review count

This commit is contained in:
Mouse Reeve 2021-01-04 17:59:46 -08:00
parent a0a8ad508a
commit 8301bec4ff
2 changed files with 2 additions and 1 deletions

View file

@ -89,7 +89,7 @@
<div class="column">
<div class="block">
<h3 class="field is-grouped">{% include 'snippets/stars.html' with rating=rating %} ({{ reviews|length }} review{{ reviews|length|pluralize }})</h3>
<h3 class="field is-grouped">{% include 'snippets/stars.html' with rating=rating %} ({{ review_count }} review{{ reviews|length|pluralize }})</h3>
{% include 'snippets/trimmed_text.html' with full=book|book_description %}

View file

@ -670,6 +670,7 @@ def book_page(request, book_id):
'title': book.title,
'book': book,
'reviews': reviews_page,
'review_count': reviews.count(),
'ratings': reviews.filter(Q(content__isnull=True) | Q(content='')),
'rating': reviews.aggregate(Avg('rating'))['rating__avg'],
'tags': models.UserTag.objects.filter(book=book),