Merge branch 'master' of github.com:Gluejar/regluit
commit
ac4a6b7570
|
@ -0,0 +1,23 @@
|
|||
"""
|
||||
a variety of errors can cause works to not get clustered by add_editions, or a new isbn can take time to get incorporated into clustering services.
|
||||
The signature of both problems is a work with only one related edition, a singleton.
|
||||
This script goes through all singleton works and attempts to add_related. 'xx' works are excluded from being source works
|
||||
"""
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db.models import Count
|
||||
from regluit.core import models, bookloader
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "add and merge editions for singleton works"
|
||||
|
||||
def handle(self, **options):
|
||||
print "Number of singleton Works with language!=xx: %s" % models.Work.objects.annotate(num_editions=Count('editions')).filter(num_editions=1).exclude(language='xx').count()
|
||||
|
||||
for work in models.Work.objects.annotate(num_editions=Count('editions')).filter(num_editions=1).exclude(language='xx'):
|
||||
#check that there's still only one edition
|
||||
if work.editions.count() != 1:
|
||||
continue
|
||||
new_editions = bookloader.add_related( work.first_isbn_13() )
|
||||
print "clustered %s editions for work %s" % (len(new_editions),work )
|
||||
print "Updated Number of singleton Works with language!=xx: %s" % models.Work.objects.annotate(num_editions=Count('editions')).filter(num_editions=1).exclude(language='xx').count()
|
|
@ -81,7 +81,7 @@ class BookLoaderTests(TestCase):
|
|||
bookloader.add_related('0441012035')
|
||||
self.assertTrue(models.Edition.objects.count() > 15)
|
||||
self.assertEqual(models.Work.objects.filter(language=lang).count(), 1)
|
||||
self.assertTrue(edition.work.editions.count() > 10)
|
||||
self.assertTrue(edition.work.editions.count() > 9)
|
||||
|
||||
|
||||
def test_populate_edition(self):
|
||||
|
|
Loading…
Reference in New Issue