<commit_before>{% extends "base.html" %}
{% block title %}Admin{% endblock %}
{% block head %}
    {{ super() }}
    <style type="text/css">
    #content ul {
        margin: 0;
        padding: 0;
    }
    #content li {
        list-style: none;
        margin: 0;
        padding: 0.3em;
        white-space: nowrap;
        font-size: 0.8em;
    }
    #content li.pending { background: #ff8; }
    #content li.claimed { background: #fa4; }
    #content li.finished { background: #8f8; }
    #content li.failed { background: #f88; }

    table {
        border-collapse: collapse;
    }
    td { padding: 0.2em 0.5em; }

    table.hidecleanup tr.cleanupable td { font-size: 0; height: 1px; background-color: #8f8; }
    td.filename { font-size: 60%; }
    td.cleanupable { text-align: center; font-size: 200%; }
    
    table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after { 
        content: " \25B4\25BE" 
    }
    td {
        border-bottom: 1px solid #eee;
    }
    time {
        display: block;
        font-style: italic;
        font-size: 80%;
    }
    #content li strong.pending { background: yellow; }
    #content li strong.claimed { background: orange; }
    #content li strong.finished { background: green; }
    #content li strong.failed { background: red; }
    #content li form { display: inline; float: right; }
    #content li { overflow: auto; }
    #content li input[type="submit"] {
        background: rgba(255,255,255,0.4);
        border-width: 0;
        color: black;
        border-radius: 4px;
    }
    </style>
    <script src="/static/sorttable.js"></script>
{% endblock %}
{% block content %}
<h1>The queue</h1>
<form action="/togglepause" method="POST">
    <input type="submit" value="{% if is_paused %}Unpause the server{% else %}Pause the server{% endif %}">
</form>
<p><button id="togglecompleted" onclick="document.querySelector('table.sortable').classList.toggle('hidecleanup')">Show/hide {{ completed_count }} completed item{% if completed_count != 1 %}s{% endif %}</button></p>
<table class="sortable hidecleanup">
    <thead><tr>
        <th>Uploaded</th><th>Click filename</th><th>Uploader</th>
        <th class="sorttable_nosort">Results</th><th class="sorttable_nosort">Ready for cleanup?</th>
    </tr></thead>
    <tbody>
{% for item in queue %}
    <tr class="{% if item.cleanupable %}cleanupable{% endif %}">
        <td sorttable_customkey="{{item.dt}}">{{item.dta|safe}} <time data-timestamp="{{item.dt}}"></time></td>
        <td class="filename"><a href="/click/{{item.uid}}">{{item.metadata.filename}}</a>
        {% if item.metadata.runid %}({{item.metadata.runid}}){% endif %}</td>
        <td>{{item.metadata.email}}</td>
        <td>
            <ul>
                {% for device in item.metadata.devices %}
                <li class="{{device.status}}" title="{{device.status}}">{{device.printable}}
                {% if device.status == "claimed" %}
                    <form method="POST" action="{{ url_for('setstatus') }}">
                    <input type="hidden" name="uid" value="{{item.uid}}">
                    <input type="hidden" name="status" value="pending">
                    <input type="hidden" name="device" value="{{device.printable}}">
                    <input type="submit" value="&#x2672;" title="Set to pending">
                    </form>
                {% endif %}
                </li>
                {% endfor %}
            </ul>
        </td>
        <td class="cleanupable {% if item.cleanupable %}yes{% else %}no{% endif %}">
        {% if item.cleanupable %}✓{% else %}❌{% endif %}
        </td>
    </tr>
{% endfor %}
</table>
<script>
function tick() {
    var now = (new Date()).getTime() / 1000;
    Array.prototype.slice.call(document.querySelectorAll("time")).forEach(function(time) {
        var diff = now - parseInt(time.getAttribute("data-timestamp"), 10);
        var s = "Some time ago";
        if (diff < 60) {
            s = "Just now!";
        } else if (diff < 60 * 2) {
            s = "A minute ago";
        } else if (diff < 60 * 5) {
            s = "A few minutes ago";
        } else if (diff < 60 * 50) {
            s = Math.round(diff / 60) + " minutes ago";
        } else if (diff < 60 * 80) {
            s = "An hour ago";
        } else if (diff < 60 * 60 * 18) {
            s = Math.round(diff / 60 / 60) + " hours ago";
        } else if (diff < 60 * 60 * 28) {
            s = "A day ago";
        } else if (diff < 60 * 60 * 24 * 6) {
            s = Math.round(diff / 60 / 60 / 24) + " days ago";
        } else {
            s = Math.round(diff / 60 / 60 / 7) + " weeks ago";
        }
        time.innerHTML = s;
        var aging = Math.min(diff, 60*60*24*7) / (60*60*24*7);
        time.parentNode.parentNode.style.backgroundColor = "rgba(248,236,194," + aging + ")";
    });
}
setInterval(tick, 30000);
tick();
</script>
{% endblock %}<commit_msg>Fix the weeks-ago timer to be actually correct<commit_after>{% extends "base.html" %}
{% block title %}Admin{% endblock %}
{% block head %}
    {{ super() }}
    <style type="text/css">
    #content ul {
        margin: 0;
        padding: 0;
    }
    #content li {
        list-style: none;
        margin: 0;
        padding: 0.3em;
        white-space: nowrap;
        font-size: 0.8em;
    }
    #content li.pending { background: #ff8; }
    #content li.claimed { background: #fa4; }
    #content li.finished { background: #8f8; }
    #content li.failed { background: #f88; }

    table {
        border-collapse: collapse;
    }
    td { padding: 0.2em 0.5em; }

    table.hidecleanup tr.cleanupable td { font-size: 0; height: 1px; background-color: #8f8; }
    td.filename { font-size: 60%; }
    td.cleanupable { text-align: center; font-size: 200%; }
    
    table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after { 
        content: " \25B4\25BE" 
    }
    td {
        border-bottom: 1px solid #eee;
    }
    time {
        display: block;
        font-style: italic;
        font-size: 80%;
    }
    #content li strong.pending { background: yellow; }
    #content li strong.claimed { background: orange; }
    #content li strong.finished { background: green; }
    #content li strong.failed { background: red; }
    #content li form { display: inline; float: right; }
    #content li { overflow: auto; }
    #content li input[type="submit"] {
        background: rgba(255,255,255,0.4);
        border-width: 0;
        color: black;
        border-radius: 4px;
    }
    </style>
    <script src="/static/sorttable.js"></script>
{% endblock %}
{% block content %}
<h1>The queue</h1>
<form action="/togglepause" method="POST">
    <input type="submit" value="{% if is_paused %}Unpause the server{% else %}Pause the server{% endif %}">
</form>
<p><button id="togglecompleted" onclick="document.querySelector('table.sortable').classList.toggle('hidecleanup')">Show/hide {{ completed_count }} completed item{% if completed_count != 1 %}s{% endif %}</button></p>
<table class="sortable hidecleanup">
    <thead><tr>
        <th>Uploaded</th><th>Click filename</th><th>Uploader</th>
        <th class="sorttable_nosort">Results</th><th class="sorttable_nosort">Ready for cleanup?</th>
    </tr></thead>
    <tbody>
{% for item in queue %}
    <tr class="{% if item.cleanupable %}cleanupable{% endif %}">
        <td sorttable_customkey="{{item.dt}}">{{item.dta|safe}} <time data-timestamp="{{item.dt}}"></time></td>
        <td class="filename"><a href="/click/{{item.uid}}">{{item.metadata.filename}}</a>
        {% if item.metadata.runid %}({{item.metadata.runid}}){% endif %}</td>
        <td>{{item.metadata.email}}</td>
        <td>
            <ul>
                {% for device in item.metadata.devices %}
                <li class="{{device.status}}" title="{{device.status}}">{{device.printable}}
                {% if device.status == "claimed" %}
                    <form method="POST" action="{{ url_for('setstatus') }}">
                    <input type="hidden" name="uid" value="{{item.uid}}">
                    <input type="hidden" name="status" value="pending">
                    <input type="hidden" name="device" value="{{device.printable}}">
                    <input type="submit" value="&#x2672;" title="Set to pending">
                    </form>
                {% endif %}
                </li>
                {% endfor %}
            </ul>
        </td>
        <td class="cleanupable {% if item.cleanupable %}yes{% else %}no{% endif %}">
        {% if item.cleanupable %}✓{% else %}❌{% endif %}
        </td>
    </tr>
{% endfor %}
</table>
<script>
function tick() {
    var now = (new Date()).getTime() / 1000;
    Array.prototype.slice.call(document.querySelectorAll("time")).forEach(function(time) {
        var diff = now - parseInt(time.getAttribute("data-timestamp"), 10);
        var s = "Some time ago";
        if (diff < 60) {
            s = "Just now!";
        } else if (diff < 60 * 2) {
            s = "A minute ago";
        } else if (diff < 60 * 5) {
            s = "A few minutes ago";
        } else if (diff < 60 * 50) {
            s = Math.round(diff / 60) + " minutes ago";
        } else if (diff < 60 * 80) {
            s = "An hour ago";
        } else if (diff < 60 * 60 * 18) {
            s = Math.round(diff / 60 / 60) + " hours ago";
        } else if (diff < 60 * 60 * 28) {
            s = "A day ago";
        } else if (diff < 60 * 60 * 24 * 14) {
            s = Math.round(diff / 60 / 60 / 24) + " days ago";
        } else {
            s = Math.round(diff / 60 / 60 / 24 / 7) + " weeks ago";
        }
        time.innerHTML = s;
        var aging = Math.min(diff, 60*60*24*7) / (60*60*24*7);
        time.parentNode.parentNode.style.backgroundColor = "rgba(248,236,194," + aging + ")";
    });
}
setInterval(tick, 30000);
tick();
</script>
{% endblock %}
{'fraction_non_alphanumeric': 0.17748264412918804, 'fraction_numerical': 0.028473689505986517, 'mean_word_length': 2.227272727272727, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 119, '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': '3192053', 'n_tokens_mistral': 3467, 'n_tokens_neox': 3099, 'n_words': 770}