From 325a9a409f11493046a4ba7463e1e3b0c829105c Mon Sep 17 00:00:00 2001 From: Phillip Jensen Date: Thu, 10 Oct 2024 10:26:51 +0200 Subject: [PATCH] Update tasks.py --- stats-backend/api2/tasks.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/stats-backend/api2/tasks.py b/stats-backend/api2/tasks.py index b0822a1..0e53c65 100644 --- a/stats-backend/api2/tasks.py +++ b/stats-backend/api2/tasks.py @@ -1856,18 +1856,7 @@ def bulk_update_node_statuses(nodes_data): if redis_updates: r.mset(redis_updates) - #Clean up duplicate consecutive statuses - with transaction.atomic(): - subquery = NodeStatusHistory.objects.filter( - node_id=OuterRef('node_id'), - timestamp__lt=OuterRef('timestamp') - ).order_by('-timestamp') - duplicate_records = NodeStatusHistory.objects.annotate( - prev_status=Subquery(subquery.values('is_online')[:1]) - ).filter(is_online=F('prev_status')) - - duplicate_records.delete() from .utils import check_node_status @app.task @@ -1911,4 +1900,4 @@ def check_missing_nodes(missing_nodes): is_online = check_node_status(node_id) nodes_to_update.append((node_id, is_online)) - bulk_update_node_statuses(nodes_to_update) \ No newline at end of file + bulk_update_node_statuses.delay(nodes_to_update) \ No newline at end of file