From a285fdf29e59c3b957247ea9241943c7202e9a28 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 21:20:40 +0100 Subject: 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. --- webmentions_ssg/db_helpers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 webmentions_ssg/db_helpers.py (limited to 'webmentions_ssg/db_helpers.py') 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 +# +# 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 -- cgit v1.3.1