aboutsummaryrefslogtreecommitdiff
path: root/tests/views/test_sources.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-18 22:07:58 +0100
committerDennis Fink2026-11-18 22:07:58 +0100
commit45d3d3fde75173dfbf27e08aae8501842a9511dd (patch)
tree96926d2ff0111e838620afdc73a66a8172bfa6c8 /tests/views/test_sources.py
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--tests/views/test_sources.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/views/test_sources.py b/tests/views/test_sources.py
index a41c18c..8f5672c 100644
--- a/tests/views/test_sources.py
+++ b/tests/views/test_sources.py
@@ -659,6 +659,37 @@ def test_resend_preserves_source_filter_context(
send.assert_called_once_with(mention_id)
+def test_sources_show_sql_statistics_with_zero_webmentions(
+ app: Flask, client: FlaskClient
+) -> None:
+ log_in(app, client)
+ make_source(
+ app,
+ "mixed-stats",
+ statuses=(
+ SentWebmentionStatus.SENT,
+ SentWebmentionStatus.SENT,
+ SentWebmentionStatus.FAILED,
+ SentWebmentionStatus.NO_ENDPOINT,
+ ),
+ )
+ make_source(app, "empty-stats", statuses=())
+
+ response = client.get("/sources", query_string={"sort": "path", "order": "asc"})
+ assert response.status_code == HTTPStatus.OK
+ rows = BeautifulSoup(response.get_data(as_text=True), "html.parser").select(
+ "tbody tr"
+ )
+ assert len(rows) == 2
+ assert "0 Total" in rows[0].get_text(" ", strip=True)
+ assert " sent" not in rows[0].get_text(" ", strip=True)
+ mixed = rows[1].get_text(" ", strip=True)
+ assert "4 Total" in mixed
+ assert "2 sent" in mixed
+ assert "1 failed" in mixed
+ assert "awaiting retry" not in mixed
+
+
def test_sources_empty_filter_result_keeps_rescan_modal(
app: Flask, client: FlaskClient
) -> None: