aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/templates
diff options
context:
space:
mode:
authorDennis Fink2026-11-18 22:07:58 +0100
committerDennis Fink2026-11-18 22:07:58 +0100
commit45d3d3fde75173dfbf27e08aae8501842a9511dd (patch)
tree96926d2ff0111e838620afdc73a66a8172bfa6c8 /webmentions_ssg/templates
parentc724c87eb5e23581732a275f1dd808da72932286 (diff)
downloadwebmentions-ssg-45d3d3fde75173dfbf27e08aae8501842a9511dd.tar.gz
webmentions-ssg-45d3d3fde75173dfbf27e08aae8501842a9511dd.zip
perf(sender): aggregate source statistics in SQL
Move sent Webmention counts from template iteration into a page-scoped SQL aggregate so source listings no longer load every related delivery row. Include zero-target sources and expose sent, no-endpoint, failed, and retrying counts directly to the template.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/templates/sent.html29
1 files changed, 11 insertions, 18 deletions
diff --git a/webmentions_ssg/templates/sent.html b/webmentions_ssg/templates/sent.html
index b613f4b..46296b8 100644
--- a/webmentions_ssg/templates/sent.html
+++ b/webmentions_ssg/templates/sent.html
@@ -84,17 +84,7 @@ SPDX-License-Identifier: BSD-3-Clause
</thead>
<tbody>
{% for source in sources %}
- {% set statistics = namespace(sent=0, failed=0, retrying=0) %}
- {% for webmention in source.sent_webmentions %}
- {% if webmention.status == "sent" %}
- {% set statistics.sent = statistics.sent + 1 %}
- {% elif webmention.status == "failed" %}
- {% set statistics.failed = statistics.failed + 1 %}
- {% endif %}
- {% if webmention.awaiting_processing and webmention.attempt_count > 0 and webmention.next_retry_at is not none %}
- {% set statistics.retrying = statistics.retrying + 1 %}
- {% endif %}
- {% endfor %}
+ {% set counts = statistics[source.uuid] %}
{% if source.deleted_at is none %}
{% set row_class = "table-success" %}
{% set badge_class = "text-bg-success" %}
@@ -115,15 +105,18 @@ SPDX-License-Identifier: BSD-3-Clause
<a href="{{ source.url }}">{{ source.url }}</a>
</td>
<td>
- <span class="badge text-bg-info">{{ source.sent_webmentions | length }} Total</span>
- {% if statistics.sent %}
- <span class="badge text-bg-success">{{ statistics.sent }} sent</span>
+ <span class="badge text-bg-info">{{ counts.total }} Total</span>
+ {% if counts.sent %}
+ <span class="badge text-bg-success">{{ counts.sent }} sent</span>
{% endif %}
- {% if statistics.failed %}
- <span class="badge text-bg-danger">{{ statistics.failed }} failed</span>
+ {% if counts.no_endpoint %}
+ <span class="badge text-bg-secondary">{{ counts.no_endpoint }} no endpoint</span>
{% endif %}
- {% if statistics.retrying %}
- <span class="badge text-bg-warning">{{ statistics.retrying }} awaiting retry</span>
+ {% if counts.failed %}
+ <span class="badge text-bg-danger">{{ counts.failed }} failed</span>
+ {% endif %}
+ {% if counts.retrying %}
+ <span class="badge text-bg-warning">{{ counts.retrying }} awaiting retry</span>
{% endif %}
</td>
<td class="d-none d-md-table-cell">{{ source.revision }}</td>