mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-26 10:00:33 +00:00
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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
{% blocktrans trimmed with title=top_rated|book_title site_name=site.name rating=top_rated.rating|floatformat:1 %}
|
{% blocktrans trimmed with title=top_rated|book_title book_path=book.local_path 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.
|
<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 %}
|
{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,8 +43,8 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
{% blocktrans trimmed with title=wanted|book_title site_name=site.name %}
|
{% blocktrans trimmed with title=wanted|book_title book_path=book.local_path site_name=site.name %}
|
||||||
More {{ site_name }} users want to read <em>{{ title }}</em>.
|
More {{ site_name }} users want to read <a href="{{ book_path }}"><em>{{ title }}</em></a>.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,8 +57,8 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
{% blocktrans trimmed with title=controversial|book_title site_name=site.name %}
|
{% blocktrans trimmed with title=controversial|book_title book_path=book.local_path site_name=site.name %}
|
||||||
<em>{{ title }}</em> has the most divisive ratings of any book on {{ site_name }}.
|
<a href="{{ book_path }}"><em>{{ title }}</em></a> has the most divisive ratings of any book on {{ site_name }}.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,17 +29,17 @@ def about(request):
|
||||||
|
|
||||||
books = models.Edition.objects.exclude(cover__exact="")
|
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(
|
data["top_rated"] = books.annotate(
|
||||||
rating=Avg("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)),
|
rating_count=Count("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||||
).annotate(
|
).annotate(
|
||||||
weighted=F("rating") * F("rating_count") / total_ratings
|
weighted=F("rating") * F("rating_count") / total_ratings
|
||||||
).filter(weighted__gt=0).order_by("-weighted").first()
|
).filter(weighted__gt=0).order_by("-weighted").first()
|
||||||
|
|
||||||
data["controversial"] = books.annotate(
|
data["controversial"] = books.annotate(
|
||||||
deviation=StdDev("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)),
|
rating_count=Count("review__rating", filter=Q(review__user__local=True, review__deleted=False)),
|
||||||
).annotate(
|
).annotate(
|
||||||
weighted=F("deviation") * F("rating_count") / total_ratings
|
weighted=F("deviation") * F("rating_count") / total_ratings
|
||||||
).filter(weighted__gt=0).order_by("-weighted").first()
|
).filter(weighted__gt=0).order_by("-weighted").first()
|
||||||
|
|
Loading…
Reference in a new issue