<commit_before>'use strict';

var plotly = require('plotly'),
    async = require('async'),
    database = require('./database');

var data = {},
    layout = {
        fileopt: 'overwrite',
        filename: 'Latest Response Times testing',
        layout: {
            showlegend: true,
            title: 'Latest Response Times'
        }
    };
plotly = plotly('servercooties', 'ismuxlxups');

function makePlot(callback) {
    var lines = Object.keys(data).map(function (key) {
        return {
            name: key,
            type: 'scatter',
            x: data[key].map(function (check) {
                var d = new Date(check.checkedAt);
                return d.toISOString().replace('T', ' ').replace('Z', '');
            }),
            y: data[key].map(function (check) {
                return check.responseTime / 1000;
            })
        };
    });
    plotly.plot(lines, layout, function () {
        callback();
    });
}

function sortData(checks) {
    var cutoff = Date.now() - 60 * 60 * 1000;
    checks.forEach(function (check) {
        var key = /\/.*$/.exec(check.key)[0],
            d = data[key] || [];
        d.push(check);
        data[key] = d;
    });
    Object.keys(data).forEach(function (key) {
        data[key] = data[key].filter(function (check) {
            return check.checkedAt >= cutoff;
        });
    });
}

function setData(check) {
    sortData([check]);
}


database.getRecentChecks(15 * 60 * 60, function (err, checks) {
    if (err) {
        return;
    }
    database.registerListener(setData);
    sortData(checks);

    async.forever(function (next) {
        makePlot(function () {
            setTimeout(next, 60 * 1000);
        });
    });
});
<commit_msg>make prod use prod graph<commit_after>'use strict';

var plotly = require('plotly'),
    async = require('async'),
    database = require('./database');

var data = {},
    layout = {
        fileopt: 'overwrite',
        filename: 'Latest Response Times',
        layout: {
            showlegend: true,
            title: 'Latest Response Times'
        }
    };
plotly = plotly('servercooties', 'ismuxlxups');

function makePlot(callback) {
    var lines = Object.keys(data).map(function (key) {
        return {
            name: key,
            type: 'scatter',
            x: data[key].map(function (check) {
                var d = new Date(check.checkedAt);
                return d.toISOString().replace('T', ' ').replace('Z', '');
            }),
            y: data[key].map(function (check) {
                return check.responseTime / 1000;
            })
        };
    });
    plotly.plot(lines, layout, function () {
        callback();
    });
}

function sortData(checks) {
    var cutoff = Date.now() - 60 * 60 * 1000;
    checks.forEach(function (check) {
        var key = /\/.*$/.exec(check.key)[0],
            d = data[key] || [];
        d.push(check);
        data[key] = d;
    });
    Object.keys(data).forEach(function (key) {
        data[key] = data[key].filter(function (check) {
            return check.checkedAt >= cutoff;
        });
    });
}

function setData(check) {
    sortData([check]);
}


database.getRecentChecks(15 * 60 * 60, function (err, checks) {
    if (err) {
        return;
    }
    database.registerListener(setData);
    sortData(checks);

    async.forever(function (next) {
        makePlot(function () {
            setTimeout(next, 60 * 1000);
        });
    });
});

{'fraction_non_alphanumeric': 0.16064721178850044, 'fraction_numerical': 0.01444669170759896, 'mean_word_length': 1.938879456706282, 'pattern_counts': {'":': 0, '<': 3, '<?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': '543509', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1035, 'n_words': 215}