Repository: bookwyrm-social/bookwyrm

Issue:
Most Beloved Book on Instance has zero local reviews
**Describe the bug**
On the About this Instance page there's a cool section that shows various books, like Most Beloved, Most Contentious, Most Wanted to Read. The Most Beloved category, however, appears to be driven by federated statistics and not local statistics. A book with no local ratings is listed as the most Beloved Book because *other* instances have rated it highly. 

**To Reproduce**
Steps to reproduce the behavior:
1. Don't have a lot of ratings on your instance.
2. Import a book that is highly rated from another (in this case 3 reviews, all 5 stars) 
3. Go to instancedomain/about and view the Most Beloved book

I'm really only guessing on these steps to reproduce, it's just something I stumbled across.

**Expected behavior**
I expect the most beloved book to be beloved by my instance, not other instances. Federated statistics would also be cool, but it doesn't seem like this section is meant to represent the network. 

**Instance**
https://tankie.ml/

---

**Smartphone (please complete the following information):**
    - Device: Samsung Galaxy A52 5G
    - OS: Android 12
    - Browser: Firefox
    - Version: 97.2.0
    


Discussion:
Yep, I'm able to replicate this locally as well. I did write the query with the intention of it filtering to only local reviews, but I must be misunderstanding something about what I wrote. Thanks for letting me know!

Resolving patch:
diff --git a/bookwyrm/templatetags/landing_page_tags.py b/bookwyrm/templatetags/landing_page_tags.py
--- a/bookwyrm/templatetags/landing_page_tags.py
+++ b/bookwyrm/templatetags/landing_page_tags.py
@@ -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)


Test patch: