<commit_before><?php

/** @postRoute */
function inject_menu($req, $unused, $args)
{
    $args['menu'] = [
        '/' => ['Portada', false],
        '/locales' => ['Locales Adheridos', false],
    ];
    if (!empty($args['menu'][$_SERVER['REQUEST_URI']])) {
        // Go home @crodas you're drunk!
        $args['menu'][$_SERVER['REQUEST_URI']][1] = true;
    }
    return $args;
}

/** @Filter id */
function get_id($req, $name, $value)
{
    $db  = Service::get('db');
    $doc = $db->GetCollection('noticia')->findOne(['_id' => new \MongoId($value)]);
    if (empty($doc)) {
        return false;
    }
    $req->set($name, $doc);
    return true;
}

/** @Filter uri */
function uri($req, $name, $value)
{
    $db  = Service::get('db');
    $doc = $db->GetCollection($name)->findOne(['uri' => $value]);
    if (empty($doc)) {
        return false;
    }
    $req->set($name, $doc);
    return true;
}

/** @Route("/go/{id:noticia}") */
function go($req)
{
    $noticia = $req->get('noticia');
    $noticia->visitas++;
    Service::get('db')->save($noticia);
    header("Location: {$noticia->url}");
    exit;
}

/** @Route("/play/audio/{id:noticia}") */
function get_audio($req)
{
    $noticia = $req->get('noticia');
    if (!$noticia->is_audio || empty($noticia->crawled_data['mp3'])) {
        $req->notFound();
    }
    $noticia->listened++;
    Service::get('db')->save($noticia);
    header("Location: {$noticia->crawled_data['mp3']}");
    exit;
}


/**
 *  @Route /locales
 *  @View locales.tpl
 */
function get_locales() {
    return [];
}

/**
 *  @Route /
 *  @View layout.tpl
 */
function get_home($req)
{
    $db = Service::get('db');
    $corruptos = $db->getCollection('corrupto')->find()->sort(['hits' => -1]);
    return compact('corruptos');
}

/**
 *  @Route "/audio/{uri:corrupto}"
 *  @Route "/audio/{uri:corrupto}/{page}"
 *  @View corrupto.tpl
 */
function get_corruptos_audio($req)
{
    $corrupto = $req->get('corrupto');
    $page     = $req->get('page') ?: 0;<commit_msg>fixed url reported by '<NAME>'<commit_after><?php

/** @postRoute */
function inject_menu($req, $unused, $args)
{
    $args['menu'] = [
        '/' => ['Portada', false],
        '/locales' => ['Locales Adheridos', false],
    ];
    if (!empty($args['menu'][$_SERVER['REQUEST_URI']])) {
        // Go home @crodas you're drunk!
        $args['menu'][$_SERVER['REQUEST_URI']][1] = true;
    }
    return $args;
}

/** @Filter id */
function get_id($req, $name, $value)
{
    $db  = Service::get('db');
    $doc = $db->GetCollection('noticia')->findOne(['_id' => new \MongoId($value)]);
    if (empty($doc)) {
        return false;
    }
    $req->set($name, $doc);
    return true;
}

/** @Filter uri */
function uri($req, $name, $value)
{
    $db  = Service::get('db');
    $doc = $db->GetCollection($name)->findOne(['uri' => $value]);
    if (empty($doc)) {
        return false;
    }
    $req->set($name, $doc);
    return true;
}

/** @Route("/go/{id:noticia}") */
function go($req)
{
    $noticia = $req->get('noticia');
    $noticia->visitas++;
    Service::get('db')->save($noticia);
    header("Location: {$noticia->url}");
    exit;
}

/** @Route("/play/audio/{id:noticia}") */
function get_audio($req)
{
    $noticia = $req->get('noticia');
    if (!$noticia->is_audio || empty($noticia->crawled_data['mp3'])) {
        $req->notFound();
    }
    $noticia->listened++;
    Service::get('db')->save($noticia);
    header("Location: {$noticia->crawled_data['mp3']}");
    exit;
}


/**
 *  @Route /locales
 *  @View locales.tpl
 */
function get_locales() {
    return [];
}

/**
 *  @Route /
 *  @View layout.tpl
 */
function get_home($req)
{
    $db = Service::get('db');
    $corruptos = $db->getCollection('corrupto')->find()->sort(['hits' => -1]);
    return compact('corruptos');
}

/**
 *  @Route "/audio/{uri:corrupto}"
 *  @View corrupto.tpl
 */
function get_corruptos_audio($req)
{
    $corrupto = $req->get('corrupto');
    $page     = $req->get('page') ?: 0;
{'fraction_non_alphanumeric': 0.24855636454933466, 'fraction_numerical': 0.0025106703489831783, 'mean_word_length': 3.198103266596417, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6925273', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1480, 'n_words': 239}