<commit_before>function list_accum(l) {
    var new_list = [];
    _.each(l, function(item, i) {
        if(i > 0) {
            new_list.push(item + new_list[i-1]);
        } else {
            new_list.push(item)
        }
    });
    return new_list;
}

function generate_date_stats(data, type, accumulate) {
    var TYPES = {
        'daily': {
            len: moment().dayOfYear() + 1,
            fun: function(x) {return moment(x).dayOfYear();}
        },
        'weekly': {
            len: moment().week() + 1,
            fun: function(x) {return moment(x).week();}
        },
        'monthly': {
            len: moment().month() + 1 + 1,
            fun: function(x) {return moment(x).month() + 1;}
        }
    }

    var series = [{
        name: 'Opened',
        data: []
    }, {
        name: 'Resolved',
        data: []
    }];

    // initialize the data
    for(var i=0;i<TYPES[type].len;i++) {
        series[0].data.push(0);
        series[1].data.push(0);
    }

    function date_valid(dt) { return moment().year() == moment(dt).year();}
    function resolved(state) { return _.indexOf(['feedback', 'monitored', 'suspended', 'closed'], item.state) >= 0}

    _.each(data, function(item) {
        if (date_valid(item.arrived_at)) {
            var pos_opened = TYPES[type].fun(item.arrived_at);
            series[0].data[pos_opened]++;

        }

        if (date_valid(item.modified_at) && resolved(item.state)) {
            var pos_resolved = TYPES[type].fun(item.modified_at);
            series[1].data[pos_resolved]++;
        }
    });

    if (accumulate) {
        series[0].data = list_accum(series[0].data);<commit_msg>fix chart issue<commit_after>function list_accum(l) {
    var new_list = [];
    _.each(l, function(item, i) {
        if(i > 0) {
            new_list.push(item + new_list[i-1]);
        } else {
            new_list.push(item)
        }
    });
    return new_list;
}

function generate_date_stats(data, type, accumulate) {
    var TYPES = {
        'daily': {
            len: moment().dayOfYear() + 1,
            fun: function(x) {return moment(x).dayOfYear();}
        },
        'weekly': {
            len: moment().week() + 1,
            fun: function(x) {return moment(x).week();}
        },
        'monthly': {
            len: moment().month() + 1 + 1,
            fun: function(x) {return moment(x).month() + 1;}
        }
    }

    var series = [{
        name: 'Opened',
        data: []
    }, {
        name: 'Resolved',
        data: []
    }];

    // initialize the data
    for(var i=0;i<TYPES[type].len;i++) {
        series[0].data.push(0);
        series[1].data.push(0);
    }

    function date_valid(dt) { return moment().year() == moment(dt).year();}
    function resolved(state) { return _.indexOf(['feedback', 'monitored', 'suspended', 'closed'], state) >= 0}

    _.each(data, function(item) {
        if (date_valid(item.arrived_at)) {
            var pos_opened = TYPES[type].fun(item.arrived_at);
            series[0].data[pos_opened]++;

        }

        if (date_valid(item.modified_at) && resolved(item.state)) {
            var pos_resolved = TYPES[type].fun(item.modified_at);
            series[1].data[pos_resolved]++;
        }
    });

    if (accumulate) {
        series[0].data = list_accum(series[0].data);
{'fraction_non_alphanumeric': 0.17434507678410116, 'fraction_numerical': 0.010237880156579343, 'mean_word_length': 1.9660714285714285, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4869793', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1096, 'n_words': 191}