diff options
| author | Dennis Fink | 2026-11-13 21:20:40 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 21:20:40 +0100 |
| commit | a285fdf29e59c3b957247ea9241943c7202e9a28 (patch) | |
| tree | 17ceeb703de23af1e67081d99a8864bbe353fb46 /webmentions_ssg/tasks/consumer.py | |
| parent | 78ecd8bc227bdcbbd0e45eea025f7223252ed0da (diff) | |
| download | webmentions-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/tasks/consumer.py | 25 |
1 files changed, 8 insertions, 17 deletions
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 |
