<commit_before>var fs = require('fs');

var db = require('../src/db/content-provider');
var timelineUtils = require('../src/utils/timeline-utils');

db.loadDatabase({}, function() {
    var commits = db.getCollection('commits');
    var githubCommits = timelineUtils.getCommitsPerDay(commits, 'github');
    var bitbucketCommits = timelineUtils.getCommitsPerDay(commits, 'bitbucket');
    var allCommits = githubCommits.concat(bitbucketCommits);

    var jsonData = allCommits.reduce(function(acc, item) {
        var currentDate = item.date;
        if (acc[currentDate] != null) {
            acc[currentDate] += item.num_commits;
        } else {
            acc[currentDate] = item.num_commits;
        }

        return acc;
    }, {});

    fs.writeFileSync('dummy-data.json', JSON.stringify(jsonData));
});
<commit_msg>sort commits by date<commit_after>var fs = require('fs');

var db = require('../src/db/content-provider');
var timelineUtils = require('../src/utils/timeline-utils');

db.loadDatabase({}, function() {
    var commits = db.getCollection('commits');
    var githubCommits = timelineUtils.getCommitsPerDay(commits, 'github');
    var bitbucketCommits = timelineUtils.getCommitsPerDay(commits, 'bitbucket');
    var allCommits = githubCommits.concat(bitbucketCommits);

    var sortedCommitsByDate = allCommits.sort(function(first, second) {
        return new Date(first.date) - new Date(second.date);
    });

    var jsonData = sortedCommitsByDate.reduce(function(acc, item) {
        var currentDate = item.date;
        if (acc[currentDate] != null) {
            acc[currentDate] += item.num_commits;
        } else {
            acc[currentDate] = item.num_commits;
        }

        return acc;
    }, {});

    fs.writeFileSync('dummy-data.json', JSON.stringify(jsonData));
});

{'fraction_non_alphanumeric': 0.14475138121546963, 'fraction_numerical': 0.0, 'mean_word_length': 3.395631067961165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4519252', 'n_tokens_mistral': 569, 'n_tokens_neox': 548, 'n_words': 100}