Skip to content

Commit 08895f0

Browse files
[fix] Add rationale comments for idempotent check creation #649
Explain use of swapper.load_model and prefetch-based deduplication logic. Fixes #649
1 parent d28514d commit 08895f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

openwisp_monitoring/check/base/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def _auto_check_receiver(sender, instance, **kwargs):
124124

125125
ct = ContentType.objects.get_for_model(instance)
126126

127+
# Prefetch existing check_types for this object to ensure idempotency
128+
# This avoids creating duplicate checks when the signal is triggered multiple times
127129
existing_check_types = set(
128130
Check.objects.filter(
129131
content_type=ct,

0 commit comments

Comments
 (0)