forked from mirrors/bookwyrm
Fixes localizing query for superlatives
This commit is contained in:
parent
d1d743281a
commit
5d7e6b872a
1 changed files with 12 additions and 4 deletions
|
@ -16,11 +16,15 @@ def get_book_superlatives():
|
|||
models.Work.objects.annotate(
|
||||
rating=Avg(
|
||||
"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(
|
||||
"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)
|
||||
|
@ -33,11 +37,15 @@ def get_book_superlatives():
|
|||
models.Work.objects.annotate(
|
||||
deviation=StdDev(
|
||||
"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(
|
||||
"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)
|
||||
|
|
Loading…
Reference in a new issue