<commit_before>import {Mongo} from 'meteor/mongo';
import {check} from 'meteor/check';

export let Pokedex = {};

Pokedex._files = [
    'contest_combos', 
    'contest_effect_prose',
    'contest_effects',
    'contest_types',
    'moves',
    'pokemon',
];
Pokedex._collections = {}
for (let i=0; i<Pokedex._files.length; i++) {
    Pokedex._collections[Pokedex._files[i]] = new Mongo.Collection(Pokedex._files[i]);
}

if (Meteor.isServer) {
    let imported = true;
    for (let i=0; i<Pokedex._files.length; i++) {
        if (Pokedex._collections[Pokedex._files[i]].find({}).count() <= 0) {
            let file = Assets.getText('data/'+Pokedex._files[i]+'.csv');
            const results = Papa.parse(file, {
                header: true,
                dynamicTyping: true,
            });
            for (let j=0; j<results.data.length; j++) {
                Pokedex._collections[Pokedex._files[i]].insert(results.data[j]);
            }
            console.log('Imported '+Pokedex._files[i]+'.csv!');
            if (Pokedex._files[i] == 'pokemon') imported = false;
        }
    }
    if (!imported) {
        let file = Assets.getText('data/pokemon_moves.csv');
        const results = Papa.parse(file, {
            header: true,
            dynamicTyping: true,
        });
        for (let j=0; j<results.data.length; j++) {
            Pokedex._collections['pokemon'].update({id: results.data[j]['pokemon_id']}, {
                $push: {moves: results.data[j]['move_id']}
            });
            if (j%1000==0) console.log(j+'/'+results.data.length+' done importing');
        }
    }

    Meteor.publish('pokemon', function pokePub() {
        return Pokedex._collections['pokemon'].find({id: {$lt: 10000}});
    });
    Meteor.publish('moves', function movePub() {
        return Pokedex._collections['moves'].find();
    });
}

Pokedex.validMoves = function(pokemon) {
    const p = Pokedex._collections.pokemon.findOne({identifier: pokemon});
    return p && p.moves && Pokedex._collections.moves.find({id: {$in: p.moves}});
}
Pokedex.eligibleMove = function(pokemon, move) {
    
}

Meteor.methods({
});

<commit_msg>push -> addToSet<commit_after>import {Mongo} from 'meteor/mongo';
import {check} from 'meteor/check';

export let Pokedex = {};

Pokedex._files = [
    'contest_combos', 
    'contest_effect_prose',
    'contest_effects',
    'contest_types',
    'moves',
    'pokemon',
];
Pokedex._collections = {}
for (let i=0; i<Pokedex._files.length; i++) {
    Pokedex._collections[Pokedex._files[i]] = new Mongo.Collection(Pokedex._files[i]);
}

if (Meteor.isServer) {
    let imported = true;
    for (let i=0; i<Pokedex._files.length; i++) {
        if (Pokedex._collections[Pokedex._files[i]].find({}).count() <= 0) {
            let file = Assets.getText('data/'+Pokedex._files[i]+'.csv');
            const results = Papa.parse(file, {
                header: true,
                dynamicTyping: true,
            });
            for (let j=0; j<results.data.length; j++) {
                Pokedex._collections[Pokedex._files[i]].insert(results.data[j]);
            }
            console.log('Imported '+Pokedex._files[i]+'.csv!');
            if (Pokedex._files[i] == 'pokemon') imported = false;
        }
    }
    if (!imported) {
        let file = Assets.getText('data/pokemon_moves.csv');
        const results = Papa.parse(file, {
            header: true,
            dynamicTyping: true,
        });
        for (let j=0; j<results.data.length; j++) {
            Pokedex._collections['pokemon'].update({id: results.data[j]['pokemon_id']}, {
                $addToSet: {moves: results.data[j]['move_id']}
            });
            if (j%1000==0) console.log(j+'/'+results.data.length+' done importing');
        }
    }

    Meteor.publish('pokemon', function pokePub() {
        return Pokedex._collections['pokemon'].find({id: {$lt: 10000}});
    });
    Meteor.publish('moves', function movePub() {
        return Pokedex._collections['moves'].find();
    });
}

Pokedex.validMoves = function(pokemon) {
    const p = Pokedex._collections.pokemon.findOne({identifier: pokemon});
    return p && p.moves && Pokedex._collections.moves.find({id: {$in: p.moves}});
}
Pokedex.eligibleMove = function(pokemon, move) {
    
}

Meteor.methods({
});


{'fraction_non_alphanumeric': 0.1753080678911881, 'fraction_numerical': 0.006975122064636131, 'mean_word_length': 2.596989966555184, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 4, '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': '6114080', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1479, 'n_words': 237}