<commit_before>// docready for modern browsers
document.addEventListener("DOMContentLoaded", function(event) {

    var datasrc = dataReposAllOfThem;
    //var datasrc = dataReposAll;
    //var datasrc = dataReposSome;
    //console.log(datasrc);

    // Sort datasource array by date
    // ------------------------------------------------------------
    datasrc.sort(function(a, b) {
        return a.author_date_unix_timestamp - b.author_date_unix_timestamp;
    });
    //console.log(datasrc);

    // Round up the date so that we can sort commits from different repos by date
    // ------------------------------------------------------------
    var roundDate = function(timeStamp) {
        var d = new Date(timeStamp);
        return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
    };

    // Create object array based on key and its value
    // ------------------------------------------------------------
    var groupByKeyAndValue = function(data, key, val) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] == val) {
                arr.push(data[i]);
            }
        }
        return arr;
    };
    var weekMonday = groupByKeyAndValue(datasrc, 'date_day_week', 'Mon');
    //console.log(weekMonday);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayByKey = function(data, key) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] === undefined) {
                data[i][key] = '0';
            }
            arr.push(data[i][key]);
        }
        return arr;
    };
    var arrayCommitNr = arrayByKey(datasrc, 'commit_nr');
    //console.log(arrayCommitNr);
    var arrayImpact = arrayByKey(datasrc, 'impact');
    //console.log(arrayImpact);
    var arrayTimestamp = arrayByKey(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayTimestamp);

    // Create array based on key value, sorted
    // ------------------------------------------------------------
    var arrayByKeySorted = function(data, key) {
        var arr = [];
        for (var i in data) {<commit_msg>Get the key in array that occurs most often<commit_after>// docready for modern browsers
document.addEventListener("DOMContentLoaded", function(event) {

    var datasrc = dataReposAllOfThem;
    //var datasrc = dataReposAll;
    //var datasrc = dataReposSome;
    //console.log(datasrc);

    // Sort datasource array by date
    // ------------------------------------------------------------
    datasrc.sort(function(a, b) {
        return a.author_date_unix_timestamp - b.author_date_unix_timestamp;
    });
    //console.log(datasrc);

    // Round up the date so that we can sort commits from different repos by date
    // ------------------------------------------------------------
    var roundDate = function(timeStamp) {
        var d = new Date(timeStamp);
        return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
    };

    // Get the key in array that occurs most often
    // ------------------------------------------------------------
    var mostOften = function(array) {
        if(array.length === 0) {
            return null;
        }
        var modeMap = {};
        var maxEl = array[0], maxCount = 1;
        for(var i = 0; i < array.length; i++) {
            var el = array[i];
            if (modeMap[el] === null) {
                modeMap[el] = 1;
            } else {
                modeMap[el]++;
            }
            if(modeMap[el] > maxCount) {
                maxEl = el;
                maxCount = modeMap[el];
            }
        }
        return maxEl;
    };

    // Create object array based on key and its value
    // ------------------------------------------------------------
    var groupByKeyAndValue = function(data, key, val) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] == val) {
                arr.push(data[i]);
            }
        }
        return arr;
    };
    var weekMonday = groupByKeyAndValue(datasrc, 'date_day_week', 'Mon');
    //console.log(weekMonday);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayByKey = function(data, key) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] === undefined) {
                data[i][key] = '0';
            }
            arr.push(data[i][key]);
        }
        return arr;
    };
    var arrayCommitNr = arrayByKey(datasrc, 'commit_nr');
    //console.log(arrayCommitNr);
    var arrayImpact = arrayByKey(datasrc, 'impact');
    //console.log(arrayImpact);
    var arrayTimestamp = arrayByKey(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayTimestamp);

    console.log(mostOften(arrayByKey(datasrc, 'date_day_week')));

    // Create array based on key value, sorted
    // ------------------------------------------------------------
    var arrayByKeySorted = function(data, key) {
        var arr = [];
        for (var i in data) {
{'fraction_non_alphanumeric': 0.2407443682664055, 'fraction_numerical': 0.002938295788442703, 'mean_word_length': 1.366079703429101, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6469264', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1376, 'n_words': 357}