mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-10 00:57:38 +03:00
Merge pull request #8 from constructorfleet/copilot/fix-mqtt-deduplication-issue
Fix ruff formatting violations in activity_manager
This commit is contained in:
commit
cb96831a0d
@ -69,15 +69,26 @@ class CameraActivityManager:
|
|||||||
|
|
||||||
# run through every zone, getting a count of objects in that zone right now
|
# run through every zone, getting a count of objects in that zone right now
|
||||||
for zone, labels in self.all_zone_labels.items():
|
for zone, labels in self.all_zone_labels.items():
|
||||||
|
# Deduplicate objects by object_id before counting
|
||||||
|
# This ensures each unique object is only counted once even if it appears
|
||||||
|
# multiple times (e.g., with custom classifications)
|
||||||
|
zone_objects_by_id = {
|
||||||
|
obj["id"]: obj for obj in all_objects if zone in obj["current_zones"]
|
||||||
|
}
|
||||||
all_zone_objects = Counter(
|
all_zone_objects = Counter(
|
||||||
obj["label"].replace("-verified", "")
|
obj["label"].replace("-verified", "")
|
||||||
for obj in all_objects
|
for obj in zone_objects_by_id.values()
|
||||||
if zone in obj["current_zones"]
|
|
||||||
)
|
)
|
||||||
active_zone_objects = Counter(
|
|
||||||
obj["label"].replace("-verified", "")
|
# Same deduplication for active objects
|
||||||
|
active_zone_objects_by_id = {
|
||||||
|
obj["id"]: obj
|
||||||
for obj in all_objects
|
for obj in all_objects
|
||||||
if zone in obj["current_zones"] and not obj["stationary"]
|
if zone in obj["current_zones"] and not obj["stationary"]
|
||||||
|
}
|
||||||
|
active_zone_objects = Counter(
|
||||||
|
obj["label"].replace("-verified", "")
|
||||||
|
for obj in active_zone_objects_by_id.values()
|
||||||
)
|
)
|
||||||
any_changed = False
|
any_changed = False
|
||||||
|
|
||||||
@ -113,13 +124,21 @@ class CameraActivityManager:
|
|||||||
def compare_camera_activity(
|
def compare_camera_activity(
|
||||||
self, camera: str, new_activity: dict[str, Any]
|
self, camera: str, new_activity: dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# Deduplicate objects by object_id before counting
|
||||||
|
# This ensures each unique object is only counted once even if it appears
|
||||||
|
# multiple times (e.g., with custom classifications)
|
||||||
|
objects_by_id = {obj["id"]: obj for obj in new_activity}
|
||||||
all_objects = Counter(
|
all_objects = Counter(
|
||||||
obj["label"].replace("-verified", "") for obj in new_activity
|
obj["label"].replace("-verified", "") for obj in objects_by_id.values()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Same deduplication for active objects
|
||||||
|
active_objects_by_id = {
|
||||||
|
obj["id"]: obj for obj in new_activity if not obj["stationary"]
|
||||||
|
}
|
||||||
active_objects = Counter(
|
active_objects = Counter(
|
||||||
obj["label"].replace("-verified", "")
|
obj["label"].replace("-verified", "")
|
||||||
for obj in new_activity
|
for obj in active_objects_by_id.values()
|
||||||
if not obj["stationary"]
|
|
||||||
)
|
)
|
||||||
any_changed = False
|
any_changed = False
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user