<commit_before><!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-31467918-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

<script>
document.addEventListener('DOMContentLoaded', onLoaded);

function onLoaded() {
    // Poll health data every minute
    fetchHealthData();
}

async function fetchHealthData() {
    var response = await fetch('/health.json');
    var json = await response.json();
    var uptimeElement = document.querySelector('#uptime');
    var updateTimeElement = document.querySelector('#updatetime');
    var healthElement = document.querySelector('#health');

    uptimeElement.textContent = formatUptime(json.uptime);
    updateTimeElement.textContent = '--';
    var lastEntry = json.health[json.health.length - 1];
    if (!lastEntry) {
        healthElement.textContent = 'data not available.';
        return;
    }
    updateTimeElement.textContent = formatUptime(Date.now() - lastEntry.timestamp);
    healthElement.innerHTML = '';
    for (var key in lastEntry) {
        var value = lastEntry[key];
        if (key === 'timestamp')
            value = new Date(value);

        var divElement = document.createElement('div');
        var keyElement = document.createElement('div');
        var valueElement = document.createElement('div');
        divElement.classList.add('health-key-value');
        keyElement.classList.add('health-key');
        valueElement.classList.add('health-value');
        divElement.appendChild(keyElement);
        divElement.appendChild(valueElement);
        healthElement.appendChild(divElement);

        keyElement.textContent = key;
        valueElement.textContent = value;
    }
}

function formatUptime(uptime) {
    var uptimeSeconds = (uptime / 1000)|0;
    var uptimeMinutes = (uptimeSeconds / 60)|0
    var uptimeHours = (uptimeMinutes / 60)|0;
    var uptimeDays = (uptimeHours / 24)|0;
    var uptimeWeeks = (uptimeDays / 7)|0;

    var seconds = uptimeSeconds % 60;
    var minutes = uptimeMinutes % 60;
    var hours = uptimeHours % 24;
    var days = uptimeDays % 7;
    var weeks = (uptimeWeeks / 7)|0;
    var result = [];
    if (weeks)
        result.push(`${weeks} weeks`);
    if (weeks || days)
        result.push(`${days} days`);
    if (weeks || days || hours)
        result.push(`${hours} hours`);
    if (weeks || days || hours || minutes)
        result.push(`${minutes} minutes`);
    result.push(`${seconds} seconds`);
    return result.join(' ');
}

</script>
<style>
body {
    font-family: monospace;
}
.health-key-value {
    display: flex;
}

.health-key-value:nth-child(even) {
    background-color: #E1F5FE;
}

.health-key {
    width: 400px;
}

</style>

<h2>
    Uptime:
    <span id="uptime">
    </span>
</h2>
<h2>
    Health data updated:
    <span id="updatetime">
    </span> ago
</h2>
<div id="health">
</div>
<commit_msg>proactively request health data<commit_after><!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-31467918-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

<script>
Promise.all([
    fetchHealthData(),
    new Promise(fulfill => document.addEventListener('DOMContentLoaded', fulfill)),
]).then(healthData => renderHealthData(healthData[0]));


async function fetchHealthData() {
    var response = await fetch('/health.json');
    return await response.json();
}

function renderHealthData(json) {
    var uptimeElement = document.querySelector('#uptime');
    var updateTimeElement = document.querySelector('#updatetime');
    var healthElement = document.querySelector('#health');

    uptimeElement.textContent = formatUptime(json.uptime);
    updateTimeElement.textContent = '--';
    var lastEntry = json.health[json.health.length - 1];
    if (!lastEntry) {
        healthElement.textContent = 'data not available.';
        return;
    }
    updateTimeElement.textContent = formatUptime(Date.now() - lastEntry.timestamp);
    healthElement.innerHTML = '';
    for (var key in lastEntry) {
        var value = lastEntry[key];
        if (key === 'timestamp')
            value = new Date(value);

        var divElement = document.createElement('div');
        var keyElement = document.createElement('div');
        var valueElement = document.createElement('div');
        divElement.classList.add('health-key-value');
        keyElement.classList.add('health-key');
        valueElement.classList.add('health-value');
        divElement.appendChild(keyElement);
        divElement.appendChild(valueElement);
        healthElement.appendChild(divElement);

        keyElement.textContent = key;
        valueElement.textContent = value;
    }
}

function formatUptime(uptime) {
    var uptimeSeconds = (uptime / 1000)|0;
    var uptimeMinutes = (uptimeSeconds / 60)|0
    var uptimeHours = (uptimeMinutes / 60)|0;
    var uptimeDays = (uptimeHours / 24)|0;
    var uptimeWeeks = (uptimeDays / 7)|0;

    var seconds = uptimeSeconds % 60;
    var minutes = uptimeMinutes % 60;
    var hours = uptimeHours % 24;
    var days = uptimeDays % 7;
    var weeks = (uptimeWeeks / 7)|0;
    var result = [];
    if (weeks)
        result.push(`${weeks} weeks`);
    if (weeks || days)
        result.push(`${days} days`);
    if (weeks || days || hours)
        result.push(`${hours} hours`);
    if (weeks || days || hours || minutes)
        result.push(`${minutes} minutes`);
    result.push(`${seconds} seconds`);
    return result.join(' ');
}

</script>
<style>
body {
    font-family: monospace;
}
.health-key-value {
    display: flex;
}

.health-key-value:nth-child(even) {
    background-color: #E1F5FE;
}

.health-key {
    width: 400px;
}

</style>

<h2>
    Uptime:
    <span id="uptime">
    --
    </span>
</h2>
<h2>
    Health data updated:
    <span id="updatetime">
    ---
    </span> ago
</h2>
<div id="health">
</div>

{'fraction_non_alphanumeric': 0.16769706336939721, 'fraction_numerical': 0.014683153013910355, 'mean_word_length': 3.3871186440677965, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '2926340', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2088, 'n_words': 408}