From 45d3d3fde75173dfbf27e08aae8501842a9511dd Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 18 Nov 2026 22:07:58 +0100 Subject: 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. --- webmentions_ssg/templates/sent.html | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'webmentions_ssg/templates') 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 {% 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 {{ source.url }} - {{ source.sent_webmentions | length }} Total - {% if statistics.sent %} - {{ statistics.sent }} sent + {{ counts.total }} Total + {% if counts.sent %} + {{ counts.sent }} sent {% endif %} - {% if statistics.failed %} - {{ statistics.failed }} failed + {% if counts.no_endpoint %} + {{ counts.no_endpoint }} no endpoint {% endif %} - {% if statistics.retrying %} - {{ statistics.retrying }} awaiting retry + {% if counts.failed %} + {{ counts.failed }} failed + {% endif %} + {% if counts.retrying %} + {{ counts.retrying }} awaiting retry {% endif %} {{ source.revision }} -- cgit v1.3.1