<commit_before>

var mysql = require('mysql');

function fetchHashTableData(db, query, id, group, callback) {
  db.query(query, function(err, rows, fields) {
    if (err) throw err;
    var data;
    if(id !== undefined){
      data = {};
    } else {
      data = [];
    }
    for (var i = 0; i < rows.length; i++){
      if(id !== undefined){
        if(data[rows[i][id]] === undefined){
          data[rows[i][id]] = {};
        }
        if(group !== undefined) {
          if(data[rows[i][id]][rows[i][group]] === undefined) {
            data[rows[i][id]][rows[i][group]] = {};
          }
          for (var j = 0; j < fields.length; j++){
            data[rows[i][id]][rows[i][group]][fields[j].name] = rows[i][fields[j].name];
          }
        } else {
          for (var j = 0; j < fields.length; j++){
            data[rows[i][id]][fields[j].name] = rows[i][fields[j].name];
          }
        }


      } else {
        data.push(rows[i]);
      }
    }
    callback(data);
  });
}

var eanaEltuConnection = mysql.createConnection({
  host: 'localhost',
  user: 'mobile',
  password: '<PASSWORD>',          // Dev Credentials - Needs to be swapped out with Prod credentials
  database: 'eanaeltu'
});

eanaEltuConnection.connect();

var eanaEltu = {};

// Fetch dictLanguages
fetchHashTableData(eanaEltuConnection, 'SELECT lc, engName, nativeName, active FROM dictLanguages', 'lc', undefined, function(data){
  eanaEltu.dictLanguages = data;
});

// Fetch dictLayout
fetchHashTableData(eanaEltuConnection, 'SELECT id, value FROM dictLayout', 'id', undefined, function(data){
  eanaEltu.dictLayout = data;
});

// Fetch dictLoc
fetchHashTableData(eanaEltuConnection, 'SELECT id, value, lc, editTime FROM dictLoc', 'id', 'lc', function(data){
  eanaEltu.dictLoc = data;
});

// Fetch dictMeta
fetchHashTableData(eanaEltuConnection, 'SELECT id, value, editTime FROM dictMeta', 'id', undefined, function(data){
  eanaEltu.dictMeta = data;
});

// Fetch dictWordTemplate
fetchHashTableData(eanaEltuConnection, 'SELECT id, format, argc, changeable FROM dictWordTemplate', 'id', undefined, function(data){
  eanaEltu.dictWordTemplate = data;
});


// dictLoc is the localization for dictMeta
// Combine them together





eanaEltuConnection.end(function(err){
    //console.log(eanaEltu);
});


<commit_msg>Completed Fetching of all EanaEltu data<commit_after>var mysql = require('mysql');

function fetchHashTableData(db, query, id, group, callback) {
    db.query(query, function (err, rows, fields) {
        if (err) throw err;
        var data;
        if (id !== undefined) {
            data = {};
        } else {
            data = [];
        }
        for (var i = 0; i < rows.length; i++) {
            if (id !== undefined) {
                if (data[rows[i][id]] === undefined) {
                    data[rows[i][id]] = {};
                }
                if (group !== undefined) {
                    if (data[rows[i][id]][rows[i][group]] === undefined) {
                        data[rows[i][id]][rows[i][group]] = {};
                    }
                    for (var j = 0; j < fields.length; j++) {
                        data[rows[i][id]][rows[i][group]][fields[j].name] = rows[i][fields[j].name];
                    }
                } else {
                    for (var j = 0; j < fields.length; j++) {
                        data[rows[i][id]][fields[j].name] = rows[i][fields[j].name];
                    }
                }


            } else {
                data.push(rows[i]);
            }
        }
        callback(data);
    });
}

var eanaEltuConnection = mysql.createConnection({
    host: 'localhost',
    user: 'mobile',
    password: '<PASSWORD>',          // Dev Credentials - Needs to be swapped out with Prod credentials
    database: 'eanaeltu'
});

eanaEltuConnection.connect();

var eanaEltu = {};

console.log("Fetching EanaEltu Data...");

// Fetch dictLanguages
fetchHashTableData(eanaEltuConnection, 'SELECT lc, engName, nativeName, active FROM dictLanguages', 'lc', undefined, function (data) {
    eanaEltu.dictLanguages = data;
});

// Fetch dictLayout
fetchHashTableData(eanaEltuConnection, 'SELECT id, value FROM dictLayout', 'id', undefined, function (data) {
    eanaEltu.dictLayout = data;
});

// Fetch dictLoc
fetchHashTableData(eanaEltuConnection, 'SELECT id, value, lc, editTime FROM dictLoc', 'id', 'lc', function (data) {
    eanaEltu.dictLoc = data;
});

// Fetch dictMeta
fetchHashTableData(eanaEltuConnection, 'SELECT id, value, editTime FROM dictMeta', 'id', undefined, function (data) {
    eanaEltu.dictMeta = data;
});

// Fetch dictOrder
fetchHashTableData(eanaEltuConnection, 'SELECT id, pos, type, data1, data2 FROM dictOrder', 'id', 'pos', function (data) {
    eanaEltu.dictOrder = data;
});

// Fetch dictWordLoc
fetchHashTableData(eanaEltuConnection, 'SELECT id, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, odd, lc, editTime FROM dictWordLoc', 'id', 'lc', function (data) {
    eanaEltu.dictWordLoc = data;
});

// Fetch dictWordMeta
fetchHashTableData(eanaEltuConnection, 'SELECT id, type, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, odd, block, editTime, audio FROM dictWordMeta', 'id', undefined, function (data) {
    eanaEltu.dictWordMeta = data;
});

// Fetch dictWordTemplate
fetchHashTableData(eanaEltuConnection, 'SELECT id, format, argc, changeable FROM dictWordTemplate', 'id', undefined, function (data) {
    eanaEltu.dictWordTemplate = data;
});

eanaEltuConnection.end(function (err) {
    console.log('Fetch Complete');
    // All data has been fetched
    // Start processing the data
    buildDictionary();
});

function buildDictionary() {
    console.log("Building Dictionary...");
    
}



{'fraction_non_alphanumeric': 0.15345758578644836, 'fraction_numerical': 0.0052255704581083435, 'mean_word_length': 2.830553702468312, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '4448222', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1860, 'n_words': 438}