From ef903b091157aa3549fd2f4446ab75f484b57de9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Jun 2023 18:05:19 -0400 Subject: [PATCH] fix duplicates in related books --- catalog/book/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/catalog/book/models.py b/catalog/book/models.py index 7f9d7a14..53ec76c3 100644 --- a/catalog/book/models.py +++ b/catalog/book/models.py @@ -167,6 +167,7 @@ class Edition(Item): works = list(self.works.all()) return ( Edition.objects.filter(works__in=works) + .distinct() .exclude(pk=self.pk) .exclude(is_deleted=True) .exclude(merged_to_item__isnull=False) @@ -179,6 +180,9 @@ class Work(Item): douban_work = PrimaryLookupIdDescriptor(IdType.DoubanBook_Work) goodreads_work = PrimaryLookupIdDescriptor(IdType.Goodreads_Work) editions = models.ManyToManyField(Edition, related_name="works") + # TODO: we have many duplicates due to 302 + # a lazy fix is to remove smaller DoubanBook_Work ids + # but ideally deal with 302 in scrape(). class Series(Item):