<commit_before>const badge = require('gh-badges');

var Badge = {};

var generate = (left, right, color) => {
    return new Promise((good, bad)=> {
        badge.loadFont('Verdana.ttf', function (err) {
            if (err) {
                return bad(err);
            }
            badge({text: [left, right], colorscheme: color, template: "flat"},
                function (svg, err) {
                    if (err) {
                        return bad(err);
                    }
                    return good(svg);
                });
        });
    })
};

Badge.upPercent = (siteName, percent) => {
    return generate('uptime', percent + '%', colorForPercent(percent))
};

Badge.status = (siteName, up) => {

    var upText = 'Down';
    var color = 'red';
    if (up) {
        upText = 'Up';
        color = 'green';
    }
    return generate(siteName, upText, color)
};

Badge.averageResponseTime = (siteName, average) => {

    var color = colorForResponseTime(average);
    average = average + 'ms';
    if (!average) {
        average = 'unknown';
        color = 'lightgrey';
    } else {

    }

    return generate('avg response time', average, color)
};

function colorForResponseTime(average) {
    if (average < 200) {
        return 'green';
    }
    else if (average < 300) {
        return 'yellowgreen';
    }
    else if (average < 500) {
        return 'yellow';
    }
    else if (average < 1000) {
        return 'orange';
    } else {
        return 'red';
    }
}

function colorForPercent(percent) {

    if (percent == 100) {
        return 'green';
    }
    else if (percent > 99) {
        return 'yellowgreen';
    }
    else if (percent > 95) {
        return 'yellow';
    }
    else if (percent > 90) {
        return 'orange';
    } else {
        return 'red';
    }

}


module.exports = Badge;<commit_msg>>98 is ok<commit_after>const badge = require('gh-badges');

var Badge = {};

var generate = (left, right, color) => {
    return new Promise((good, bad)=> {
        badge.loadFont('Verdana.ttf', function (err) {
            if (err) {
                return bad(err);
            }
            badge({text: [left, right], colorscheme: color, template: "flat"},
                function (svg, err) {
                    if (err) {
                        return bad(err);
                    }
                    return good(svg);
                });
        });
    })
};

Badge.upPercent = (siteName, percent) => {
    return generate('uptime', percent + '%', colorForPercent(percent))
};

Badge.status = (siteName, up) => {

    var upText = 'Down';
    var color = 'red';
    if (up) {
        upText = 'Up';
        color = 'green';
    }
    return generate(siteName, upText, color)
};

Badge.averageResponseTime = (siteName, average) => {

    var color = colorForResponseTime(average);
    average = average + 'ms';
    if (!average) {
        average = 'unknown';
        color = 'lightgrey';
    } else {

    }

    return generate('avg response time', average, color)
};

function colorForResponseTime(average) {
    if (average < 200) {
        return 'green';
    }
    else if (average < 300) {
        return 'yellowgreen';
    }
    else if (average < 500) {
        return 'yellow';
    }
    else if (average < 1000) {
        return 'orange';
    } else {
        return 'red';
    }
}

function colorForPercent(percent) {

    if (percent > 98) {
        return 'yellowgreen';
    }
    else if (percent > 95) {
        return 'yellow';
    }
    else if (percent > 90) {
        return 'orange';
    } else {
        return 'red';
    }

}


module.exports = Badge;
{'fraction_non_alphanumeric': 0.1434460016488046, 'fraction_numerical': 0.011816433086012641, 'mean_word_length': 1.774390243902439, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '2699624', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1092, 'n_words': 281}