Skip to content

Commit

Permalink
Check that there are no duplicate popit_url entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mhl committed Feb 2, 2015
1 parent be8ea0d commit 82bb11c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pombola/core/management/commands/core_fix_sayit_speakers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections import Counter
import re
import sys

from django.conf import settings
from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -115,11 +117,26 @@ def safely_delete(p):
if all_deleted:
p.delete()

def check_for_duplicate_urls():
# Check that there are no duplicate popit_url entries:
popit_url_counter = Counter()
for p in PopItPerson.objects.all():
popit_url_counter[p.popit_url] += 1
duplicate_urls_found = False
for popit_url, count in popit_url_counter.items():
if count > 1:
print "There were multiple entries for " + popit_url
duplicate_urls_found = True
if duplicate_urls_found:
sys.exit(1)


class Command(BaseCommand):

def handle(*args, **options):

check_for_duplicate_urls()

popit_url_to_pk = {p.popit_url: p.id for p in PopItPerson.objects.all()}

# Build up some preliminary mappings:
Expand Down

0 comments on commit 82bb11c

Please sign in to comment.