<commit_before><?php
require_once('../../global_functions.php');
require_once('../functions.php');
require_once('../../connections/parameters.php');

//THIS LISTS ALL THE ACTIVE MODS ON THE SITE

try {
    $memcache = new Memcache;
    $memcache->connect("localhost", 11211); # You might need to set "localhost" to "127.0.0.1"

    $popularMods = $memcache->get('api_lobby_d2mods_list');
    if (!$popularMods) {
        $popularMods = array();
        $db = new dbWrapper_v2($hostname_gds_site, $username_gds_site, $password_gds_site, $database_gds_site);
        if ($db) {
            $modListActive = simple_cached_query('api_lobby_d2mods_list_active',
                'SELECT
                        ml.*,
                        (SELECT COUNT(*) FROM `mod_match_overview` mmo WHERE mmo.`mod_id` = ml.`mod_identifier` AND mmo.`match_recorded` >= now() - INTERVAL 7 DAY AND mmo.`match_duration` > 130 GROUP BY `mod_id`) AS games_last_week,
                        (SELECT COUNT(*) FROM `mod_match_overview` mmo WHERE mmo.`mod_id` = ml.`mod_identifier` AND mmo.`match_duration` > 130 GROUP BY `mod_id`) AS games_all_time
                    FROM `mod_list` ml
                    WHERE ml.`mod_active` = 1
                    HAVING games_all_time > 0
                    ORDER BY games_last_week DESC, games_all_time DESC;'
                , 30
            );

            if (!empty($modListActive)) {
                foreach ($modListActive as $key => $value) {
                    $temp = array();

                    $temp['modName'] = !empty($value['mod_name'])
                        ? $value['mod_name']
                        : 'Unknown Mod';

                    $temp['workshopID'] = !empty($value['mod_workshop_link'])
                        ? $value['mod_workshop_link']
                        : 0;

                    !empty($key)
                        ? $temp['popularityRank'] = $key + 1
                        : NULL;

                    !empty($value['games_last_week'])
                        ? $temp['gamesLastWeek'] = number_format($value['games_last_week'])
                        : $temp['gamesLastWeek'] = 0;

                    !empty($value['games_all_time'])
                        ? $temp['gamesAllTime'] = number_format($value['games_all_time'])
                        : $temp['gamesAllTime'] = 0;

                    !empty($value['mod_maps'])
                        ? $temp['mod_maps'] = $value['mod_maps']
                        : NULL;

                    $popularMods[] = $temp;
                }
            } else {
                $popularMods['error'] = 'No active mods!';
            }
        } else {
            $popularMods['error'] = 'No DB connection!';
        }

        $memcache->set('api_lobby_d2mods_list', $popularMods, 0, 1 * 60);
    }

    $memcache->close();
} catch (Exception $e) {
    unset($popularMods);
    $popularMods['error'] = 'Caught Exception: ' . $e->getMessage() . '<br /> Contact getdotastats.com';
}

echo utf8_encode(json_encode($popularMods));<commit_msg>Remove number formatting on lobby_mod_list<commit_after><?php
require_once('../../global_functions.php');
require_once('../functions.php');
require_once('../../connections/parameters.php');

//THIS LISTS ALL THE ACTIVE MODS ON THE SITE

try {
    $memcache = new Memcache;
    $memcache->connect("localhost", 11211); # You might need to set "localhost" to "127.0.0.1"

    $popularMods = $memcache->get('api_lobby_d2mods_list');
    if (!$popularMods) {
        $popularMods = array();
        $db = new dbWrapper_v2($hostname_gds_site, $username_gds_site, $password_gds_site, $database_gds_site);
        if ($db) {
            $modListActive = simple_cached_query('api_lobby_d2mods_list_active',
                'SELECT
                        ml.*,
                        (SELECT COUNT(*) FROM `mod_match_overview` mmo WHERE mmo.`mod_id` = ml.`mod_identifier` AND mmo.`match_recorded` >= now() - INTERVAL 7 DAY AND mmo.`match_duration` > 130 GROUP BY `mod_id`) AS games_last_week,
                        (SELECT COUNT(*) FROM `mod_match_overview` mmo WHERE mmo.`mod_id` = ml.`mod_identifier` AND mmo.`match_duration` > 130 GROUP BY `mod_id`) AS games_all_time
                    FROM `mod_list` ml
                    WHERE ml.`mod_active` = 1
                    HAVING games_all_time > 0
                    ORDER BY games_last_week DESC, games_all_time DESC;'
                , 30
            );

            if (!empty($modListActive)) {
                foreach ($modListActive as $key => $value) {
                    $temp = array();

                    $temp['modName'] = !empty($value['mod_name'])
                        ? $value['mod_name']
                        : 'Unknown Mod';

                    $temp['workshopID'] = !empty($value['mod_workshop_link'])
                        ? $value['mod_workshop_link']
                        : 0;

                    !empty($key)
                        ? $temp['popularityRank'] = $key + 1
                        : NULL;

                    !empty($value['games_last_week'])
                        ? $temp['gamesLastWeek'] = $value['games_last_week']
                        : $temp['gamesLastWeek'] = 0;

                    !empty($value['games_all_time'])
                        ? $temp['gamesAllTime'] = $value['games_all_time']
                        : $temp['gamesAllTime'] = 0;

                    !empty($value['mod_maps'])
                        ? $temp['mod_maps'] = $value['mod_maps']
                        : NULL;

                    $popularMods[] = $temp;
                }
            } else {
                $popularMods['error'] = 'No active mods!';
            }
        } else {
            $popularMods['error'] = 'No DB connection!';
        }

        $memcache->set('api_lobby_d2mods_list', $popularMods, 0, 1 * 60);
    }

    $memcache->close();
} catch (Exception $e) {
    unset($popularMods);
    $popularMods['error'] = 'Caught Exception: ' . $e->getMessage() . '<br /> Contact getdotastats.com';
}

echo utf8_encode(json_encode($popularMods));
{'fraction_non_alphanumeric': 0.13866579249303393, 'fraction_numerical': 0.011473528929683658, 'mean_word_length': 1.7204636647347302, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1182498', 'n_tokens_mistral': 1948, 'n_tokens_neox': 1750, 'n_words': 337}