forked from mirrors/bookwyrm
Link to books
This commit is contained in:
parent
d690224559
commit
461bfd0ce7
2 changed files with 11 additions and 11 deletions
|
@ -29,8 +29,8 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="media-content">
|
||||
{% blocktrans trimmed with title=top_rated|book_title site_name=site.name rating=top_rated.rating|floatformat:1 %}
|
||||
<em>{{ title }}</em> is {{ site_name }}'s most beloved book, with an average rating of {{ rating }} out of 5.
|
||||
{% blocktrans trimmed with title=top_rated|book_title book_path=book.local_path site_name=site.name rating=top_rated.rating|floatformat:1 %}
|
||||
<a href="{{ book_path }}"><em>{{ title }}</em></a> is {{ site_name }}'s most beloved book, with an average rating of {{ rating }} out of 5.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,8 +43,8 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="media-content">
|
||||
{% blocktrans trimmed with title=wanted|book_title site_name=site.name %}
|
||||
More {{ site_name }} users want to read <em>{{ title }}</em>.
|
||||
{% blocktrans trimmed with title=wanted|book_title book_path=book.local_path site_name=site.name %}
|
||||
More {{ site_name }} users want to read <a href="{{ book_path }}"><em>{{ title }}</em></a>.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -57,8 +57,8 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="media-content">
|
||||
{% blocktrans trimmed with title=controversial|book_title site_name=site.name %}
|
||||
<em>{{ title }}</em> has the most divisive ratings of any book on {{ site_name }}.
|
||||
{% blocktrans trimmed with title=controversial|book_title book_path=book.local_path site_name=site.name %}
|
||||
<a href="{{ book_path }}"><em>{{ title }}</em></a> has the most divisive ratings of any book on {{ site_name }}.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -29,17 +29,17 @@ def about(request):
|
|||
|
||||
books = models.Edition.objects.exclude(cover__exact="")
|
||||
|
||||
total_ratings = models.Review.objects.filter(user__local=True).count()
|
||||
total_ratings = models.Review.objects.filter(user__local=True, deleted=False).count()
|
||||
data["top_rated"] = books.annotate(
|
||||
rating=Avg("review__rating", filter=Q(review__user__local=True)),
|
||||
rating_count=Count("review__rating", filter=Q(review__user__local=True)),
|
||||
rating=Avg("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||
rating_count=Count("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||
).annotate(
|
||||
weighted=F("rating") * F("rating_count") / total_ratings
|
||||
).filter(weighted__gt=0).order_by("-weighted").first()
|
||||
|
||||
data["controversial"] = books.annotate(
|
||||
deviation=StdDev("review__rating", filter=Q(review__user__local=True)),
|
||||
rating_count=Count("review__rating", filter=Q(review__user__local=True)),
|
||||
deviation=StdDev("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||
rating_count=Count("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||
).annotate(
|
||||
weighted=F("deviation") * F("rating_count") / total_ratings
|
||||
).filter(weighted__gt=0).order_by("-weighted").first()
|
||||
|
|
Loading…
Reference in a new issue