Improve Searching

Fix ordering of searches to be most-recent first
Fix for fixed-game tests not matching due to wrong arguments
Display datestamps for searched tests
Modify base template block to drop the <tr> tags
This commit is contained in:
andrew committed 2023-08-18 13:09:26 -04:00
1 parent a1f8efb55a
commit f76de2bc56
5 files changed
+29 -4

No files matched your search

+1 -1
View File
@@ -382,7 +382,7 @@ def search(request):
filtered.append(test) filtered.append(test)
error = 'No matching tests found' if not len(filtered) else None error = 'No matching tests found' if not len(filtered) else None
return render(request, 'search.html', { 'tests' : filtered }, error=error) return render(request, 'search.html', { 'tests' : reversed(filtered) }, error=error)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# GENERAL DATA TABLE VIEWS # # GENERAL DATA TABLE VIEWS #
@@ -1,5 +1,4 @@
{% load mytags %} {% load mytags %}
<tr>
<td><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td> <td><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td>
<td>{{test.dev_engine}}</td> <td>{{test.dev_engine}}</td>
<td> <td>
@@ -13,4 +12,3 @@
{% if test.dev_time_control != test.base_time_control %} <span style="color: yellow">*</span> {% endif %} {% if test.dev_time_control != test.base_time_control %} <span style="color: yellow">*</span> {% endif %}
</td> </td>
<td class='statblock statblock-{{test|testResultColour}}'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td> <td class='statblock statblock-{{test|testResultColour}}'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
</tr>
+16
View File
@@ -23,6 +23,7 @@
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
{
var timestamps = document.getElementsByClassName('timestamp'); var timestamps = document.getElementsByClassName('timestamp');
var options = { var options = {
@@ -36,6 +37,21 @@
var date = new Date(1000 * timestamps[i].innerHTML); var date = new Date(1000 * timestamps[i].innerHTML);
timestamps[i].innerHTML = date.toLocaleString(undefined, options); timestamps[i].innerHTML = date.toLocaleString(undefined, options);
} }
}
{
var datestamps = document.getElementsByClassName('datestamp');
var options = {
year : 'numeric', month : '2-digit',
day : '2-digit',
};
for (var i = 0; i < datestamps.length; i++) {
var date = new Date(1000 * datestamps[i].innerHTML);
datestamps[i].innerHTML = date.toLocaleString(undefined, options);
}
}
}, false); }, false);
</script> </script>
+8
View File
@@ -11,7 +11,9 @@
{% if pending %} {% if pending %}
<tr class="table-header"><th colspan='6'>Pending</th></tr> <tr class="table-header"><th colspan='6'>Pending</th></tr>
{% for test in pending %} {% for test in pending %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %} {% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %} {% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr> <tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %} {% endif %}
@@ -20,7 +22,9 @@
{% if awaiting %} {% if awaiting %}
<tr class="table-header"><th colspan='6'>Awaiting Artifacts</th></tr> <tr class="table-header"><th colspan='6'>Awaiting Artifacts</th></tr>
{% for test in awaiting %} {% for test in awaiting %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %} {% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %} {% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr> <tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %} {% endif %}
@@ -29,7 +33,9 @@
{% if active %} {% if active %}
<tr class="table-header"><th colspan='6'>Active {{status}}</th></tr> <tr class="table-header"><th colspan='6'>Active {{status}}</th></tr>
{% for test in active %} {% for test in active %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %} {% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %} {% endfor %}
<tr class="table-spacer"><th colspan='6'></th></tr> <tr class="table-spacer"><th colspan='6'></th></tr>
{% endif %} {% endif %}
@@ -39,7 +45,9 @@
<!-- Tests which have already finished --> <!-- Tests which have already finished -->
<tr class="table-header"><th colspan='6'>Finished</th></tr> <tr class="table-header"><th colspan='6'>Finished</th></tr>
{% for test in completed %} {% for test in completed %}
<tr>
{% include "OpenBench/Blocks/testsummary.html" %} {% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %} {% endfor %}
</table> </table>
+4 -1
View File
@@ -65,7 +65,7 @@
<select id="test-mode" name="test-mode"> <select id="test-mode" name="test-mode">
<option value="" selected>All Test Types</option> <option value="" selected>All Test Types</option>
<option value="SPRT">SPRT</option> <option value="SPRT">SPRT</option>
<option value="FIXED">FIXED</option> <option value="GAMES">FIXED</option>
</select><br> </select><br>
</div> </div>
<div class="row"> <div class="row">
@@ -150,7 +150,10 @@
<table class="test-list stripes hoverable"> <table class="test-list stripes hoverable">
{% for test in tests %} {% for test in tests %}
<tr>
<td class="datestamp">{{test.creation|date:"U"}}</td>
{% include "OpenBench/Blocks/testsummary.html" %} {% include "OpenBench/Blocks/testsummary.html" %}
</tr>
{% endfor %} {% endfor %}
</table> </table>
{% endblock %} {% endblock %}