fix(sign): filter only active panels in orphan check command

This commit is contained in:
kdeterme 2026-09-12 08:27:29 +02:00
parent 025ddd09fc
commit db70f8fba9

View file

@ -132,18 +132,18 @@ class Command(BaseCommand):
poles_by_coord[ck] = [] poles_by_coord[ck] = []
poles_by_coord[ck].append(pole) poles_by_coord[ck].append(pole)
# Pre-load attached panels per pole # Pre-load attached panels per pole (only active)
attached_types_by_pole = {} attached_types_by_pole = {}
for p in panels_qs.filter(pole__isnull=False).iterator(): for p in panels_qs.filter(pole__isnull=False, status="active").iterator():
if p.pole_id not in attached_types_by_pole: if p.pole_id not in attached_types_by_pole:
attached_types_by_pole[p.pole_id] = set() attached_types_by_pole[p.pole_id] = set()
if p.signpanel_type_id: if p.signpanel_type_id:
attached_types_by_pole[p.pole_id].add(p.signpanel_type_id) attached_types_by_pole[p.pole_id].add(p.signpanel_type_id)
orphan_panels = list( orphan_panels = list(
panels_qs.filter(pole__isnull=True, lon__isnull=False, lat__isnull=False) panels_qs.filter(pole__isnull=True, lon__isnull=False, lat__isnull=False, status="active")
) )
self.stdout.write(f"Total panneaux orphelins avec coordonnées : {len(orphan_panels)}") self.stdout.write(f"Total panneaux orphelins actifs avec coordonnées : {len(orphan_panels)}")
orphan_exact_duplicates = [] orphan_exact_duplicates = []
orphan_attachable_candidates = [] orphan_attachable_candidates = []