<commit_before><?php

/**
 * Generates blog routes
 *
 * @package     Nails
 * @subpackage  module-blog
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Blog;

use Nails\Common\Interfaces\RouteGenerator;

class Routes implements RouteGenerator
{
    /**
     * Returns an array of routes for this module
     * @return array
     */
    public static function generate()
    {
        $oDb            = Factory::service('ConsoleDatabase', 'nailsapp/module-console');
        $oModel         = Factory::model('Blog', 'nailsapp/module-blog');
        $oSettingsModel = Factory::model('AppSetting');
        $aRoutes        = [];

        $oRows = $oDb->query('SELECT id FROM ' . $oModel->getTableName());
        if (!$oRows->rowCount()) {
            return [];
        }

        while ($oRow = $oRows->fetch(PDO::FETCH_OBJ)) {

            //  Look up the setting
            $oSettings = $oDb->query('
              SELECT * FROM ' . $oSettingsModel->getTableName() . '
              WHERE `grouping` = "blog-' . $oRow->id . '"
              AND `key` = "url"

            ');

            $sUrl = json_decode($oSettings->fetch(PDO::FETCH_OBJ)->value) ?: 'blog';
            $sUrl = preg_replace('/^\//', '', $sUrl);
            $sUrl = preg_replace('/\/$/', '', $sUrl);

            $aRoutes[$sUrl . '(/(.+))?'] = 'blog/' . $oRow->id . '/$2';
        }

        return $aRoutes;
    }
}
<commit_msg>Ficing Route Generator<commit_after><?php

/**
 * Generates blog routes
 *
 * @package     Nails
 * @subpackage  module-blog
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Blog;

use Nails\Common\Interfaces\RouteGenerator;
use Nails\Factory;

class Routes implements RouteGenerator
{
    /**
     * Returns an array of routes for this module
     * @return array
     */
    public static function generate()
    {
        $oDb            = Factory::service('ConsoleDatabase', 'nailsapp/module-console');
        $oModel         = Factory::model('Blog', 'nailsapp/module-blog');
        $oSettingsModel = Factory::model('AppSetting');
        $aRoutes        = [];

        $oRows = $oDb->query('SELECT id FROM ' . $oModel->getTableName());
        if (!$oRows->rowCount()) {
            return [];
        }

        while ($oRow = $oRows->fetch(PDO::FETCH_OBJ)) {

            //  Look up the setting
            $oSettings = $oDb->query('
              SELECT * FROM ' . $oSettingsModel->getTableName() . '
              WHERE `grouping` = "blog-' . $oRow->id . '"
              AND `key` = "url"

            ');

            $sUrl = json_decode($oSettings->fetch(PDO::FETCH_OBJ)->value) ?: 'blog';
            $sUrl = preg_replace('/^\//', '', $sUrl);
            $sUrl = preg_replace('/\/$/', '', $sUrl);

            $aRoutes[$sUrl . '(/(.+))?'] = 'blog/' . $oRow->id . '/$2';
        }

        return $aRoutes;
    }
}

{'fraction_non_alphanumeric': 0.1725085910652921, 'fraction_numerical': 0.0006872852233676976, 'mean_word_length': 1.911, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '7007610', 'n_tokens_mistral': 928, 'n_tokens_neox': 897, 'n_words': 180}