<commit_before>from django.core.management.base import NoArgsCommand
from django.conf import settings
from popit import PopIt
from speeches.models import Speaker

class Command(NoArgsCommand):
    help = 'Populates the database with people from Popit'

    def handle_noargs(self, **options):
        api = PopIt(instance = settings.POPIT_INSTANCE,
                    hostname = settings.POPIT_HOSTNAME,
                    api_version = settings.POPIT_API_VERSION)
        results = api.person.get()
        for person in results['results']:
            speaker, created = Speaker.objects.get_or_create(popit_id=person['_id'])
            # we ignore created for now, just always set the name
            speaker.name = person['name']
            speaker.save();<commit_msg>Update speaker population command to set popit_url instead of popit_id<commit_after>import logging
from django.core.management.base import NoArgsCommand
from django.conf import settings
from popit import PopIt
from speeches.models import Speaker

logger = logging.getLogger(__name__)

class Command(NoArgsCommand):

    help = 'Populates the database with people from Popit'

    def handle_noargs(self, **options):
        api = PopIt(instance = settings.POPIT_INSTANCE,
                    hostname = settings.POPIT_HOSTNAME,
                    api_version = settings.POPIT_API_VERSION)
        results = api.person.get()
        for person in results['results']:

            logger.warn('Processing: {0}'.format(person['meta']['api_url']))
            
            speaker, created = Speaker.objects.get_or_create(popit_url=person['meta']['api_url'])

            logger.warn('Person was created? {0}'.format(created))
            logger.warn('Persons id in the spoke db is: {0}'.format(speaker.id))

            # we ignore created for now, just always set the name
            speaker.name = person['name']
            speaker.save();
{'fraction_non_alphanumeric': 0.09285341679707877, 'fraction_numerical': 0.001564945226917058, 'mean_word_length': 2.874747474747475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556348', 'n_tokens_mistral': 521, 'n_tokens_neox': 510, 'n_words': 142}