Merge branch 'master' of github.com:Gluejar/regluit

pull/1/head
Ed Summers 2012-01-17 15:56:46 +00:00
commit a20e01c5b2
1 changed files with 0 additions and 19 deletions

View File

@ -1,19 +0,0 @@
from django.db.models import Count
from django.core.management.base import BaseCommand
from regluit.core import models
class Command(BaseCommand):
help = "remove duplicates"
def handle(self, *args, **options):
q = models.Edition.objects.values("googlebooks_id")
q = q.annotate(Count("googlebooks_id"))
for r in q:
if r['googlebooks_id__count'] == 1:
continue
gb = r['googlebooks_id']
editions = models.Edition.objects.filter(googlebooks_id=gb)
for e in editions[1:]:
print "removing duplicate edition: %s" % e
e.delete()