mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-01 22:11:16 +00:00
Merge pull request #1988 from bookwyrm-social/superlives
Keeps "superlatives" on about page local
This commit is contained in:
commit
886448efc4
2 changed files with 27 additions and 17 deletions
|
@ -14,23 +14,25 @@
|
||||||
{% cache 604800 about_page %}
|
{% cache 604800 about_page %}
|
||||||
|
|
||||||
{% get_book_superlatives as superlatives %}
|
{% get_book_superlatives as superlatives %}
|
||||||
<section class="content pb-4">
|
<section class=" pb-4">
|
||||||
<h2>
|
<div class="content">
|
||||||
{% blocktrans with site_name=site.name %}Welcome to {{ site_name }}!{% endblocktrans %}
|
<h2>
|
||||||
</h2>
|
{% blocktrans with site_name=site.name %}Welcome to {{ site_name }}!{% endblocktrans %}
|
||||||
|
</h2>
|
||||||
|
|
||||||
<p class="subtitle notification has-background-primary-highlight">
|
<p class="subtitle notification has-background-primary-highlight">
|
||||||
{% blocktrans trimmed with site_name=site.name %}
|
{% blocktrans trimmed with site_name=site.name %}
|
||||||
{{ site_name }} is part of <em>BookWyrm</em>, a network of independent, self-directed communities for readers.
|
{{ site_name }} is part of <em>BookWyrm</em>, a network of independent, self-directed communities for readers.
|
||||||
While you can interact seamlessly with users anywhere in the <a href="https://joinbookwyrm.com/instances/" target="_blank">BookWyrm network</a>, this community is unique.
|
While you can interact seamlessly with users anywhere in the <a href="https://joinbookwyrm.com/instances/" target="_blank">BookWyrm network</a>, this community is unique.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
{% if superlatives.top_rated %}
|
{% if superlatives.top_rated %}
|
||||||
{% with book=superlatives.top_rated.default_edition rating=superlatives.top_rated.rating %}
|
{% with book=superlatives.top_rated.default_edition rating=superlatives.top_rated.rating %}
|
||||||
<div class="column is-one-third is-flex">
|
<div class="column is-one-third is-flex">
|
||||||
<div class="media notification">
|
<div class="media notification is-clipped">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<a href="{{ book.local_path }}">
|
<a href="{{ book.local_path }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
||||||
|
@ -49,7 +51,7 @@
|
||||||
{% if superlatives.wanted %}
|
{% if superlatives.wanted %}
|
||||||
{% with book=superlatives.wanted.default_edition %}
|
{% with book=superlatives.wanted.default_edition %}
|
||||||
<div class="column is-one-third is-flex">
|
<div class="column is-one-third is-flex">
|
||||||
<div class="media notification">
|
<div class="media notification is-clipped">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<a href="{{ book.local_path }}">
|
<a href="{{ book.local_path }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
||||||
|
@ -68,7 +70,7 @@
|
||||||
{% if superlatives.controversial %}
|
{% if superlatives.controversial %}
|
||||||
{% with book=superlatives.controversial.default_edition %}
|
{% with book=superlatives.controversial.default_edition %}
|
||||||
<div class="column is-one-third is-flex">
|
<div class="column is-one-third is-flex">
|
||||||
<div class="media notification">
|
<div class="media notification is-clipped">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
<a href="{{ book.local_path }}">
|
<a href="{{ book.local_path }}">
|
||||||
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %}
|
||||||
|
|
|
@ -16,11 +16,15 @@ def get_book_superlatives():
|
||||||
models.Work.objects.annotate(
|
models.Work.objects.annotate(
|
||||||
rating=Avg(
|
rating=Avg(
|
||||||
"editions__review__rating",
|
"editions__review__rating",
|
||||||
filter=Q(editions__review__local=True, editions__review__deleted=False),
|
filter=Q(
|
||||||
|
editions__review__user__local=True, editions__review__deleted=False
|
||||||
|
),
|
||||||
),
|
),
|
||||||
rating_count=Count(
|
rating_count=Count(
|
||||||
"editions__review",
|
"editions__review",
|
||||||
filter=Q(editions__review__local=True, editions__review__deleted=False),
|
filter=Q(
|
||||||
|
editions__review__user__local=True, editions__review__deleted=False
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.annotate(weighted=F("rating") * F("rating_count") / total_ratings)
|
.annotate(weighted=F("rating") * F("rating_count") / total_ratings)
|
||||||
|
@ -33,11 +37,15 @@ def get_book_superlatives():
|
||||||
models.Work.objects.annotate(
|
models.Work.objects.annotate(
|
||||||
deviation=StdDev(
|
deviation=StdDev(
|
||||||
"editions__review__rating",
|
"editions__review__rating",
|
||||||
filter=Q(editions__review__local=True, editions__review__deleted=False),
|
filter=Q(
|
||||||
|
editions__review__user__local=True, editions__review__deleted=False
|
||||||
|
),
|
||||||
),
|
),
|
||||||
rating_count=Count(
|
rating_count=Count(
|
||||||
"editions__review",
|
"editions__review",
|
||||||
filter=Q(editions__review__local=True, editions__review__deleted=False),
|
filter=Q(
|
||||||
|
editions__review__user__local=True, editions__review__deleted=False
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.annotate(weighted=F("deviation") * F("rating_count") / total_ratings)
|
.annotate(weighted=F("deviation") * F("rating_count") / total_ratings)
|
||||||
|
|
Loading…
Reference in a new issue