<commit_before>from hashlib import md5

from django.db.models import Count, Sum
from django.shortcuts import render
from django.utils.translation import ugettext as _

from judge.models import Language


def language(request):
    language_count = Language.objects.annotate(count=Count('submission'))
    languages = list(language_count.filter(count__gte=1000).values('key', 'name', 'short_name', 'count')
                                   .order_by('-count'))
    for language in languages:
        hash = md5(language['key']).hexdigest()[:6]
        r, g, b = int(hash[:2], 16), int(hash[2:4], 16), int(hash[4:6], 16),
        language['color'] = '#%02X%02X%02X' % (r, g, b)
        language['highlight'] = '#%02X%02X%02X' % (max(int(r * 1.2), 255),
                                                   max(int(g * 1.2), 255),
                                                   max(int(b * 1.2), 255))
    return render(request, 'stats/language.jade', {
        'title': _('Language statistics'), 'tab': 'language',
        'languages': languages,
        'other': language_count.filter(count__lt=1000).aggregate(total=Sum('count'))['total']
    })<commit_msg>min not max #237<commit_after>from hashlib import md5

from django.db.models import Count, Sum
from django.shortcuts import render
from django.utils.translation import ugettext as _

from judge.models import Language


def language(request):
    language_count = Language.objects.annotate(count=Count('submission'))
    languages = list(language_count.filter(count__gte=1000).values('key', 'name', 'short_name', 'count')
                                   .order_by('-count'))
    for language in languages:
        hash = md5(language['key']).hexdigest()[:6]
        r, g, b = int(hash[:2], 16), int(hash[2:4], 16), int(hash[4:6], 16),
        language['color'] = '#%02X%02X%02X' % (r, g, b)
        language['highlight'] = '#%02X%02X%02X' % (min(int(r * 1.2), 255),
                                                   min(int(g * 1.2), 255),
                                                   min(int(b * 1.2), 255))
    return render(request, 'stats/language.jade', {
        'title': _('Language statistics'), 'tab': 'language',
        'languages': languages,
        'other': language_count.filter(count__lt=1000).aggregate(total=Sum('count'))['total']
    })
{'fraction_non_alphanumeric': 0.1621505376344086, 'fraction_numerical': 0.043440860215053764, 'mean_word_length': 2.5565749235474007, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4078862', 'n_tokens_mistral': 767, 'n_tokens_neox': 694, 'n_words': 153}