From 50ee282f2953c9e4b4a395f25001fe7285aeff63 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 28 Oct 2024 13:30:19 -0400 Subject: [PATCH 1/2] simplify sitemaps --- core/models/bibmodels.py | 5 +---- core/sitemaps.py | 12 +----------- core/tests.py | 2 +- urls.py | 3 +-- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/core/models/bibmodels.py b/core/models/bibmodels.py index 9b70fd6e..80a6b2b9 100644 --- a/core/models/bibmodels.py +++ b/core/models/bibmodels.py @@ -518,11 +518,8 @@ class Work(models.Model): self.save() def priority(self): - if self.last_campaign(): - return 5 - freedom = 1 if self.is_free else 0 wishing = int(math.log(self.num_wishes)) + 1 if self.num_wishes else 0 - return min(freedom + wishing, 5) + return min(1 + wishing, 5) def first_oclc(self): if self.preferred_edition is None: diff --git a/core/sitemaps.py b/core/sitemaps.py index 1792b2da..605645a6 100644 --- a/core/sitemaps.py +++ b/core/sitemaps.py @@ -7,17 +7,7 @@ class WorkSitemap(Sitemap): limit = 10000 def items(self): - return Work.objects.all() + return Work.objects.filter(is_free=True) def priority(self,work): return '{:.1f}'.format(work.priority()/5.0) - -class PublisherSitemap(Sitemap): - priority = 0.2 - protocol = 'https' - - def items(self): - return Edition.objects.exclude(publisher_name__isnull=True).order_by('publisher_name__name').values('publisher_name').distinct() - - def location(self, pub): - return reverse("bypubname_list",args=[pub['publisher_name']]) diff --git a/core/tests.py b/core/tests.py index 5e76e184..9e34a77c 100755 --- a/core/tests.py +++ b/core/tests.py @@ -774,7 +774,7 @@ class WishlistTest(TestCase): user.wishlist.add_work(work, 'test') self.assertEqual(user.wishlist.works.count(), 1) self.assertEqual(work.num_wishes, num_wishes+1) - self.assertEqual(work.priority(),1) + self.assertEqual(work.priority(), 2) user.wishlist.remove_work(work) self.assertEqual(user.wishlist.works.count(), 0) self.assertEqual(work.num_wishes, num_wishes) diff --git a/urls.py b/urls.py index 0b01e76a..1b9c4c98 100755 --- a/urls.py +++ b/urls.py @@ -6,12 +6,11 @@ from django.views.decorators.cache import never_cache from ckeditor_uploader import views as ckedit_views from regluit.admin import site -from regluit.core.sitemaps import WorkSitemap, PublisherSitemap +from regluit.core.sitemaps import WorkSitemap from regluit.frontend.views import static_redirect_view sitemaps = { 'works': WorkSitemap, - 'publishers': PublisherSitemap, } urlpatterns = [ From 03e71be2df32bcd4a47eae4b7d2710802dc73e4a Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 28 Oct 2024 13:30:55 -0400 Subject: [PATCH 2/2] remove expensive cover_image query --- core/tasks.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/tasks.py b/core/tasks.py index 99c429e5..f5fe2def 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -231,9 +231,5 @@ def feature_new_work(): @task def make_cover_thumbnail(url, geom_string, **options): success = covers.make_cover_thumbnail(url, geom_string, **options) - if not success and url != '': - for ed in models.Edition.objects.filter(cover_image=url): - logger.error('bad cover image %s for edition: %s', url, ed.id) - #ed.cover_image = '' - #ed.save() + logger.error('bad cover image %s: %s', url) \ No newline at end of file