<commit_before>/* jshint -W097 */// jshint strict:false
/*jslint node: true */
"use strict";
// THIS file should be identical with sql and history adapter's one

function initAggregate(options) {

    //step; // 1 Step is 1 second
    if (options.step === null) {
        options.step = (options.end - options.start) / options.count;
    }

    // Limit 2000
    if ((options.end - options.start) / options.step > options.limit) {
        options.step = (options.end - options.start) / options.limit;
    }

    options.maxIndex       = Math.ceil(((options.end - options.start) / options.step) - 1);
    options.result         = [];
    options.averageCount   = [];
    options.aggregate      = options.aggregate || 'minmax';
    options.overallLength  = 0;

    // pre-fill the result with timestamps (add one before start and one after end)
    for (var i = 0; i <= options.maxIndex + 2; i++){

        options.result[i] = {
            val:    {ts: null, val: null},
            max:    {ts: null, val: null},
            min:    {ts: null, val: null},
            start:  {ts: null, val: null},
            end:    {ts: null, val: null}
        };

        if (options.aggregate === 'average') options.averageCount[i] = 0;
    }
    return options;
}

function aggregation(options, data) {
    var index;
    var preIndex;
    for (var i = 0; i < data.length; i++) {
        if (!data[i]) continue;<commit_msg>try to get rid of weired cases where only one count is wanted<commit_after>/* jshint -W097 */// jshint strict:false
/*jslint node: true */
"use strict";
// THIS file should be identical with sql and history adapter's one

function initAggregate(options) {

    //step; // 1 Step is 1 second
    if (options.step === null) {
        options.step = (options.end - options.start) / options.count;
    }

    // Limit 2000
    if ((options.end - options.start) / options.step > options.limit) {
        options.step = (options.end - options.start) / options.limit;
    }

    options.maxIndex       = Math.ceil(((options.end - options.start) / options.step) - 1);
    if (options.maxIndex === 0) options.maxIndex = 1;
    options.result         = [];
    options.averageCount   = [];
    options.aggregate      = options.aggregate || 'minmax';
    options.overallLength  = 0;

    // pre-fill the result with timestamps (add one before start and one after end)
    for (var i = 0; i <= options.maxIndex + 2; i++){

        options.result[i] = {
            val:    {ts: null, val: null},
            max:    {ts: null, val: null},
            min:    {ts: null, val: null},
            start:  {ts: null, val: null},
            end:    {ts: null, val: null}
        };

        if (options.aggregate === 'average') options.averageCount[i] = 0;
    }
    return options;
}

function aggregation(options, data) {
    var index;
    var preIndex;
    for (var i = 0; i < data.length; i++) {
        if (!data[i]) continue;
{'fraction_non_alphanumeric': 0.14368600682593857, 'fraction_numerical': 0.010921501706484642, 'mean_word_length': 2.1448497854077253, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5151124', 'n_tokens_mistral': 962, 'n_tokens_neox': 902, 'n_words': 276}