Merge pull request #1065 from Gluejar/maintenance-2024
simplify sitemap, remove expensive cover_image querypull/94/head
commit
f8023913a0
|
@ -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:
|
||||
|
|
|
@ -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']])
|
||||
|
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
|
3
urls.py
3
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 = [
|
||||
|
|
Loading…
Reference in New Issue