<commit_before>const moment = require("moment");
const widgetUtils = require("../widgetUtils");

module.exports = function(options, callback) {
    // get the oldest issue
    options.db.issue.find({pull_request:null, closed_at:null}, {created_at:1}).sort({created_at: 1}).toArray().then(results => {
        if (results.length == 0) { return callback(); }

        var counts = {
            weekly: {}, 
            monthly: {}
        };

        var earliest = "9999-99-99";
        results.forEach(function(r) {
            if (r.created_at < earliest) earliest = r.created_at;
            widgetUtils.timeIncrementGroupings.forEach(function(g) {
                var dbt = widgetUtils.datesBetween(r.created_at, r.closed_at, g[1], g[2]);
                dbt.forEach(function(datePeriod) {
                    if (!counts[g[0]][datePeriod]) { counts[g[0]][datePeriod] = 0; }
                    counts[g[0]][datePeriod] += 1;
                })
            })
        })

        var weeklyValues = Object.entries(counts.weekly).sort((a,b) => {
            if (a[0]<b[0]) return -1;<commit_msg>Have openIssuesLine not die if there's no data (issue #67)<commit_after>const moment = require("moment");
const widgetUtils = require("../widgetUtils");

module.exports = function(options, callback) {
    // get the oldest issue
    options.db.issue.find({pull_request:null, closed_at:null}, {created_at:1}).sort({created_at: 1}).toArray().then(results => {
        var counts = {
            weekly: {}, 
            monthly: {}
        };

        var earliest = "9999-99-99";
        results.forEach(function(r) {
            if (r.created_at < earliest) earliest = r.created_at;
            widgetUtils.timeIncrementGroupings.forEach(function(g) {
                var dbt = widgetUtils.datesBetween(r.created_at, r.closed_at, g[1], g[2]);
                dbt.forEach(function(datePeriod) {
                    if (!counts[g[0]][datePeriod]) { counts[g[0]][datePeriod] = 0; }
                    counts[g[0]][datePeriod] += 1;
                })
            })
        })

        var weeklyValues = Object.entries(counts.weekly).sort((a,b) => {
            if (a[0]<b[0]) return -1;
{'fraction_non_alphanumeric': 0.1565934065934066, 'fraction_numerical': 0.019688644688644688, 'mean_word_length': 2.213235294117647, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6324671', 'n_tokens_mistral': 690, 'n_tokens_neox': 655, 'n_words': 115}