<commit_before>from pyramid.view import view_config
import statatat.models as m


@view_config(route_name='stats', renderer='stats.mak')
def stats(request):
    """ Show the stats page """
    num_users = m.User.query.count()
    num_repos = m.Repo.query.count()
    num_enabled_repos = m.Repo.query.filter_by(enabled=True).count()

    # Show the top 'n' in various categories.
    n = 5

    latest_registered = m.User.query\
            .order_by(m.User.created_on.desc()).limit(n).all()

    all_users = m.User.query.all()
    by_total_enabled_repos = sorted(
        all_users,
        lambda x, y: cmp(x.total_enabled_repos, y.total_enabled_repos)
    )[:n]
    by_percent_enabled_repos = sorted(
        all_users,
        lambda x, y: cmp(x.percent_enabled_repos, y.percent_enabled_repos)
    )[:n]
    return locals()<commit_msg>Get the ordering right for the stats lists.<commit_after>from pyramid.view import view_config
import statatat.models as m


@view_config(route_name='stats', renderer='stats.mak')
def stats(request):
    """ Show the stats page """
    num_users = m.User.query.count()
    num_repos = m.Repo.query.count()
    num_enabled_repos = m.Repo.query.filter_by(enabled=True).count()

    # Show the top 'n' in various categories.
    n = 5

    latest_registered = m.User.query\
            .order_by(m.User.created_on.desc()).limit(n).all()

    all_users = m.User.query.all()
    by_total_enabled_repos = sorted(
        all_users,
        lambda x, y: cmp(x.total_enabled_repos, y.total_enabled_repos),
        reverse=True,
    )[:n]
    by_percent_enabled_repos = sorted(
        all_users,
        lambda x, y: cmp(x.percent_enabled_repos, y.percent_enabled_repos),
        reverse=True,
    )[:n]
    return locals()
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.001141552511415525, 'mean_word_length': 3.163895486935867, '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': '4904816', 'n_tokens_mistral': 620, 'n_tokens_neox': 589, 'n_words': 120}