<commit_before>from celery.task import task
from namelist.scrape import get_user_profile_id, scrape_profile, NotFound
from namelist.models import Player, Category

@task()
def import_user(profile_name_or_id, category=None, user=None, join_date=None):
    try:
        profile_id = int(profile_name_or_id)
    except ValueError:
        try:
            profile_id = get_user_profile_id(profile_name_or_id)
        except NotFound:
            if user:
                user.message_set.create(message="Couldn't create {0}".format(profile_name_or_id))
            return

    info = scrape_profile(profile_id)

    player, created = Player.objects.get_or_create(profile_id=profile_id)
    if created:
        player.category = category
        player.name = info[0]
        player.join_date = info[2]
    player.group_name = info[1]
    player.save()<commit_msg>Fixed admin interface so categories actually get set if they aren't already set.<commit_after>from celery.task import task
from namelist.scrape import get_user_profile_id, scrape_profile, NotFound
from namelist.models import Player, Category

@task()
def import_user(profile_name_or_id, category=None, user=None, join_date=None):
    try:
        profile_id = int(profile_name_or_id)
    except ValueError:
        try:
            profile_id = get_user_profile_id(profile_name_or_id)
        except NotFound:
            if user:
                user.message_set.create(message="Couldn't create {0}".format(profile_name_or_id))
            return

    info = scrape_profile(profile_id)

    player, created = Player.objects.get_or_create(profile_id=profile_id)
    if created:
        player.name = info[0]
        player.join_date = info[2]
    player.group_name = info[1]
    if not player.category:
        player.category = category
    player.save()
{'fraction_non_alphanumeric': 0.08264462809917356, 'fraction_numerical': 0.004407713498622589, 'mean_word_length': 3.2232558139534886, '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': '3480758', 'n_tokens_mistral': 567, 'n_tokens_neox': 547, 'n_words': 120}