Compute the number of works corresponding to new editions

pull/1/head
Raymond Yee 2012-02-06 11:34:11 -08:00
parent 3a2cece7dd
commit 26e8024eb2
1 changed files with 3 additions and 1 deletions

View File

@ -30,8 +30,10 @@ class Command(BaseCommand):
continue continue
if work.first_isbn_13(): if work.first_isbn_13():
new_editions = bookloader.add_related( work.first_isbn_13() ) new_editions = bookloader.add_related( work.first_isbn_13() )
corresponding_works = set([ed.work for ed in new_editions])
print "clustered %s editions for work %s" % (len(new_editions),work ), \ print "clustered %s editions for work %s" % (len(new_editions),work ), \
"| Corresponding works : ", [(w.id, w.language, w.editions.count()) for w in set([ed.work for ed in new_editions])] "| Corresponding works : ", [(w.id, w.language, w.editions.count()) for w in corresponding_works], \
"#corresponding_works:%s" % (len(corresponding_works))
else: else:
print "no ISBN for this work and therefore no new editions" print "no ISBN for this work and therefore no new editions"
print "Updated Number of singleton Works with language = %s: %s" % (language,models.Work.objects.annotate(num_editions=Count('editions')).filter(num_editions=1, language=language).count() ) print "Updated Number of singleton Works with language = %s: %s" % (language,models.Work.objects.annotate(num_editions=Count('editions')).filter(num_editions=1, language=language).count() )