<commit_before>var $db = require('../lib/mongo');
var debug = require('debug')('wol:leaderboard');

exports.process = function(game, match) {
    match.teams = []; /* teams[teamId] = [player1, player3] */

    // create player entry
    var $players = $db.get(game +'_players');
    match.players.forEach(function(player) {
        /* typically Computer */
        if (!player.nam) {
            player.nam = 'Computer';
            return;
        }

        // TODO: increase player map count
        var stats = {
            $push: {games: match.idno},
            $inc: {points: 1}
        };

        /* evaluate wolv2 completions */
        if (player.cmp) {
            switch (player.cmp) {
                case 2:
                    stats.$inc.disconnects = 1;
                break;

                case 256:
                    stats.$inc.points += 3;
                    stats.$inc.wins = 1;
                break;

                case 512:
                case 528:
                    stats.$inc.losses = 1;
                break;
            }
        }

        /* remove unused info */
        delete player.ipa; /* could be tunnel or p2p (unreliable) */
        delete player.ser; /* serials are not used on CnCNet */

        $players.update({name: player.nam}, stats, {upsert: true});

        /* associate player by teamId */
        match.teams[player.tid] = match.teams[player.id] || [];
        match.teams[player.tid].push(player.nam);

        /* tack on stats so it can be referenced in game object */
        player.__gains = stats.$inc;
    });<commit_msg>Update index.js<commit_after>var $db = require('../lib/mongo');
var debug = require('debug')('wol:leaderboard');

exports.process = function(game, match) {
    match.teams = []; /* teams[teamId] = [player1, player3] */

    // create player entry
    var $players = $db.get(game +'_players');
    match.players.forEach(function(player) {
        /* typically Computer */
        if (!player.nam) {
            player.nam = 'Computer';
            return;
        }

        // TODO: increase player map count
        var stats = {
            $push: {games: match.idno},
            $inc: {points: 1}
        };

        /* evaluate wolv2 completions */
        if (player.cmp) {
            switch (player.cmp) {
                case 2:
                    stats.$inc.disconnects = 1;
                break;

                case 256:
                    stats.$inc.points += 3;
                    stats.$inc.wins = 1;
                break;

                case 512:
                case 528:
                    stats.$inc.losses = 1;
                break;
            }
        }

        /* remove unused info */
        delete player.ipa; /* could be tunnel or p2p (unreliable) */
        delete player.addr; /* same reason but for ra1 */
        delete player.ser; /* serials are not used on CnCNet */

        $players.update({name: player.nam}, stats, {upsert: true});

        /* associate player by teamId */
        match.teams[player.tid] = match.teams[player.id] || [];
        match.teams[player.tid].push(player.nam);

        /* tack on stats so it can be referenced in game object */
        player.__gains = stats.$inc;
    });
{'fraction_non_alphanumeric': 0.13310685608400247, 'fraction_numerical': 0.012044471896232242, 'mean_word_length': 1.4482237339380197, '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': '7527605', 'n_tokens_mistral': 975, 'n_tokens_neox': 896, 'n_words': 230}