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/tasks/consumer.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'webmentions_ssg/tasks/consumer.py') diff --git a/webmentions_ssg/tasks/consumer.py b/webmentions_ssg/tasks/consumer.py index 474e775..362ebe8 100644 --- a/webmentions_ssg/tasks/consumer.py +++ b/webmentions_ssg/tasks/consumer.py @@ -21,23 +21,14 @@ def create_consumer() -> Huey: """ app = create_app() - schedule = crontab(*app.config["SCANNER_SCHEDULE"].split(), strict=True) - queue.periodic_task(schedule)(scanner.scan_sources) - - recovery_schedule = crontab( - *app.config["VERIFICATION_REAPER_SCHEDULE"].split(), strict=True - ) - queue.periodic_task(recovery_schedule)(receiver.recover_stale_webmentions) - - notification_schedule = crontab( - *app.config["NOTIFICATION_SCHEDULE"].split(), strict=True - ) - queue.periodic_task(notification_schedule)(notifications.send_webmention_digest) - - retention_schedule = crontab( - *app.config["RECEIVED_RETENTION_SCHEDULE"].split(), strict=True - ) - queue.periodic_task(retention_schedule)(retention.purge_old_received_webmentions) + for config_key, task in ( + ("SCANNER_SCHEDULE", scanner.scan_sources), + ("VERIFICATION_REAPER_SCHEDULE", receiver.recover_stale_webmentions), + ("NOTIFICATION_SCHEDULE", notifications.send_webmention_digest), + ("RECEIVED_RETENTION_SCHEDULE", retention.purge_old_received_webmentions), + ): + schedule = crontab(*app.config[config_key].split(), strict=True) + queue.periodic_task(schedule)(task) return queue.huey -- cgit v1.3.1