[webapps/foss-public-alert-server] foss_public_alert_server: Expire old connection flag table entries
Volker Krause <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 4c61167c2411aabbd273110fc02943153e757955 by Volker Krause.
Committed on 05/08/2026 at 16:58.
Pushed by vkrause into branch 'master'.
Expire old connection flag table entries
Prevents that table from growing without bounds. This isn't done very
aggressively though, as even the inactive entries provide useful
diagnostic information.
M +4 -0 foss_public_alert_server/foss_public_alert_server/celery.py
M +10 -1 foss_public_alert_server/subscriptionHandler/tasks.py
https://invent.kde.org/webapps/foss-public-alert-server/-/commit/4c61167c2411aabbd273110fc02943153e757955
diff --git a/foss_public_alert_server/foss_public_alert_server/celery.py b/foss_public_alert_server/foss_public_alert_server/celery.py
index db7941b48..ed3569983 100644
--- a/foss_public_alert_server/foss_public_alert_server/celery.py
+++ b/foss_public_alert_server/foss_public_alert_server/celery.py
@@ -85,6 +85,10 @@ app.conf.beat_schedule = {
'schedule': crontab(minute="*/5"),
'enabled': True
},
+ 'expire_connection_flags': {
+ 'task': 'task.expire_connection_flags',
+ 'schedule': crontab(minute="0", hour="0"),
+ },
}
app.conf.timezone = 'UTC' # @todo fix timezone
diff --git a/foss_public_alert_server/subscriptionHandler/tasks.py b/foss_public_alert_server/subscriptionHandler/tasks.py
index 0354e1eb4..f236a57ed 100644
--- a/foss_public_alert_server/subscriptionHandler/tasks.py
+++ b/foss_public_alert_server/subscriptionHandler/tasks.py
@@ -11,7 +11,7 @@ from alertHandler.models import Alert
from requests import ReadTimeout, RequestException, HTTPError, ConnectionError
from .exceptions import PushNotificationException, PushNotificationExpiredException
-from .models import Subscription
+from .models import ConnectionFlag, Subscription
from configuration.models import AppSetting
from .push_notification_services import unified_push, apn, firebase, unified_push_encrpted
@@ -170,3 +170,12 @@ def check_for_alerts_and_send_notifications(alert: Alert, is_update: bool = Fals
)
# @TODO(Nucleus): check performance
pass
+
+
+@shared_task(name="task.expire_connection_flags")
+def expire_connection_flags() -> None:
+ """
+ Delete old connection flag table entries to prevent that from growing without bounds.
+ """
+ cutoff_time = datetime.now(timezone.utc) - timedelta(days=60)
+ ConnectionFlag.objects.filter(set_time_stamp__lt=cutoff_time).delete()