Report 100 most recent results where missing=true

Closes: #16
This commit is contained in:
Edward Betts 2023-12-15 11:16:35 +00:00
parent 65e3de1b57
commit 223cdc4728
2 changed files with 51 additions and 0 deletions

View file

@ -371,6 +371,15 @@ def reports() -> str:
.limit(50)
)
missing_places = (
database.session.query(model.LookupLog)
.filter(
model.LookupLog.result.has_key("missing") # type: ignore
) # Filtering for entries where result contains 'missing'
.order_by(model.LookupLog.dt.desc()) # Ordering by dt in descending order
.limit(50) # Limiting to the top 50 results
)
return render_template(
"reports.html",
log_count=log_count,
@ -378,6 +387,7 @@ def reports() -> str:
average_response_time=average_response_time,
by_day=by_day,
top_places=top_places,
missing_places=missing_places,
)

View file

@ -14,6 +14,47 @@
<p>Average response time: {{ average_response_time | int }} milliseconds</p>
<h4>requests per day</h4>
<table class="table table-hover w-auto">
{% for day, day_count in by_day %}
<tr>
<td class="text-end">{{ day.strftime("%a %d %b %Y") }}</td>
<td class="text-end">{{ "{:,d}".format(day_count) }}</td>
</tr>
{% endfor %}
</table>
<h4>top places</h4>
<table class="table table-hover w-auto">
{% for place, place_count in top_places %}
<tr>
<td class="text-end">
{% if place %}
<a href="https://commons.wikimedia.org/wiki/Category:{{ place }}">{{ place }}</a>
{% else %}
<span class="badge bg-danger">no place found</span>
{% endif %}
</td>
<td class="text-end">{{ "{:,d}".format(place_count) }}</td>
</tr>
{% endfor %}
</table>
<h4>missing places</h4>
<p>Recent queries that failed to resolve into a place with a category.</p>
<table class="table table-hover w-auto">
{% for log in missing_places %}
<tr>
<td class="text-end">{{ log.dt.strftime("%a %d %b %Y at %H:%M:%S") }}</td>
<td class="text-end">
<a href="{{ url_for("detail_page", lat=log.lat, lon=log.lon) }}">
{{ "{:.3f},{:.3f}".format(log.lat, log.lon) }}
</a>
</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}