<commit_before><?php

function display_contact_page() {
    return tpl_render('contact.html', array(
        'page' => array(
            'title'       => 'Contact',
            'keywords'    => array( 'contact', 'ip7' ),
            'description' => 'Contactez-nous'
        )
    ));
}

function display_sitemap_page() {
    return tpl_render('sitemap.html', array(
        'page' => array(
            'title'       => 'Plan du site',
            'keywords'    => array( 'sitemap', 'plan du site' ),
            'description' => 'Plan du site'
        )
    ));
}

function display_legals_page() {
    return tpl_render('legals.html', array(
        'page' => array(
            'title'       => 'Mentions légales',
            'keywords'    => array( 'mentions légales' ),
            'description' => 'Mentions légales'
        )
    ));
}

function display_apropos_page() {
    return tpl_render('apropos.html', array(
        'page' => array(
            'title' => 'À Propos d\'IP7'
        )
    ));
}

function display_stats_page() {

    $authors_count = ContentQuery::create()
            ->filterByValidated(true)
            ->withColumn('COUNT(*)', 'contents_count')
            ->groupBy('AuthorId');

    $max_contributions = ContentQuery::create()
            ->addSelectQuery($authors_count, 'ac')
            ->where('ac.contents_count=(SELECT MAX(ac.contents_count))')
            ->findOne();

    $downloads_count = FileQuery::create()
                        ->withColumn('SUM(downloads_count)', 'downloads')
                        ->select('downloads')
                        ->findOne();

    $contents_count = ContentQuery::create()->filterByValidated(true)->count();
    $files_count    = FileQuery::create()->count();
    $best_contributor = $max_contributions->getAuthor();
    $best_contributor_count = ContentQuery::create()
                                    ->filterByValidated(true)
                                    ->filterByAuthor($best_contributor)
                                    ->count();

    return tpl_render('stats.html', array(
        'page' => array(
            'title' => 'Statistiques',<commit_msg>DB query fixed, fixes #238<commit_after><?php

function display_contact_page() {
    return tpl_render('contact.html', array(
        'page' => array(
            'title'       => 'Contact',
            'keywords'    => array( 'contact', 'ip7' ),
            'description' => 'Contactez-nous'
        )
    ));
}

function display_sitemap_page() {
    return tpl_render('sitemap.html', array(
        'page' => array(
            'title'       => 'Plan du site',
            'keywords'    => array( 'sitemap', 'plan du site' ),
            'description' => 'Plan du site'
        )
    ));
}

function display_legals_page() {
    return tpl_render('legals.html', array(
        'page' => array(
            'title'       => 'Mentions légales',
            'keywords'    => array( 'mentions légales' ),
            'description' => 'Mentions légales'
        )
    ));
}

function display_apropos_page() {
    return tpl_render('apropos.html', array(
        'page' => array(
            'title' => 'À Propos d\'IP7'
        )
    ));
}

function display_stats_page() {

    // number of accepted contents per author
    $contents_counts = ContentQuery::create()
                            ->filterByValidated(true)
                            ->groupBy('AuthorId')
                            ->withColumn('COUNT(*)', 'contents_count')
                            ->select(array('AuthorId', 'contents_count'))
                            ->find();

    $max = 0;
    $best_contributor_id = 0;

    foreach ($contents_counts as $_ => $cc) {
        if ($cc['contents_count'] > $max) {
            $max = $cc['contents_count'];
            $best_contributor_id = $cc['AuthorId'];
        }
    }

    $downloads_count = FileQuery::create()
                        ->withColumn('SUM(downloads_count)', 'downloads')
                        ->select('downloads')
                        ->findOne();

    $contents_count         = ContentQuery::create()->filterByValidated(true)->count();
    $files_count            = FileQuery::create()->count();
    $best_contributor       = UserQuery::create()->findOneById($best_contributor_id);
    $best_contributor_count = ContentQuery::create()
                                    ->filterByValidated(true)
                                    ->filterByAuthor($best_contributor)
                                    ->count();

    return tpl_render('stats.html', array(
        'page' => array(
            'title' => 'Statistiques',
{'fraction_non_alphanumeric': 0.14791621679982725, 'fraction_numerical': 0.0019434247462751025, 'mean_word_length': 1.8226691042047531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4009832', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1305, 'n_words': 228}