<commit_before>module.exports=function db(action, user_id, callback) {

    let pg = require('pg');

    pg.defaults.ssl = true;
    pg.connect(process.env.DATABASE_URL, function (err, client) {
        if (err) {
            console.log('Error connecting to messenger id DB, retrying');
            console.log(err);
            return db(callback);
        }
        console.log('Connected to postgres! Getting schemas...');

        client
            .query(`select exists (select messenger_id from bay_schema.id_table where messenger_id=\'${user_id}\');`, function (err, res) {
                let exists=true;
                if(res.length==0){
                    exists=false;
                }
                if(action==1 && !exists){
                    client.query(`INSERT INTO bay_schema.id_table values(\'${user_id}\');`, [], (err, res)=>{
                        if(err) {
                            console.log(err);
                            callback(err, undefined);
                            client.end((err)=>{
                                console.log(err);
                            });
                        }else{<commit_msg>Fixed calling length on undefined<commit_after>module.exports=function db(action, user_id, callback) {

    let pg = require('pg');

    pg.defaults.ssl = true;
    pg.connect(process.env.DATABASE_URL, function (err, client) {
        if (err) {
            console.log('Error connecting to messenger id DB, retrying');
            console.log(err);
            return db(callback);
        }
        console.log('Connected to postgres! Getting schemas...');

        client
            .query(`select exists (select messenger_id from bay_schema.id_table where messenger_id=\'${user_id}\');`, function (err, res) {
                let exists=true;
                if(res == undefined){
                    exists=false;
                }
                if(action==1 && !exists){
                    client.query(`INSERT INTO bay_schema.id_table values(\'${user_id}\');`, [], (err, res)=>{
                        if(err) {
                            console.log(err);
                            callback(err, undefined);
                            client.end((err)=>{
                                console.log(err);
                            });
                        }else{
{'fraction_non_alphanumeric': 0.12665245202558637, 'fraction_numerical': 0.001279317697228145, 'mean_word_length': 1.3938775510204082, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6102561', 'n_tokens_mistral': 617, 'n_tokens_neox': 580, 'n_words': 126}