aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/db_helpers.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 21:20:40 +0100
committerDennis Fink2026-11-13 21:20:40 +0100
commita285fdf29e59c3b957247ea9241943c7202e9a28 (patch)
tree17ceeb703de23af1e67081d99a8864bbe353fb46 /webmentions_ssg/db_helpers.py
parent78ecd8bc227bdcbbd0e45eea025f7223252ed0da (diff)
downloadwebmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.tar.gz
webmentions-ssg-a285fdf29e59c3b957247ea9241943c7202e9a28.zip
refactor(core): consolidate repeated helper logic
Centralize SQL row counts, hostname parsing, and content-type normalization so tasks, forms, and scanners share consistent implementations. Simplify periodic task registration and admin lookups with table-driven setup and Flask-SQLAlchemy's built-in 404 helper.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/db_helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/webmentions_ssg/db_helpers.py b/webmentions_ssg/db_helpers.py
new file mode 100644
index 0000000..6e1c2d2
--- /dev/null
+++ b/webmentions_ssg/db_helpers.py
@@ -0,0 +1,14 @@
+# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""Helpers for interpreting SQLAlchemy database results."""
+
+from typing import Any, cast
+
+from sqlalchemy.engine import CursorResult, Result
+
+
+def rows_affected(result: Result[Any]) -> int:
+ """Return the row count from a SQL UPDATE or DELETE result."""
+ return cast(CursorResult[Any], result).rowcount