Skip to content

NVR with realtime local object detection for IP cameras

Fix search sort when using score or estimated speed (#17629)

Josh Hawkins049c5cfa9d48
diff --git a/frigate/api/event.py b/frigate/api/event.py
index c4c763bf7d..84994f20ac 100644
--- a/frigate/api/event.py
+++ b/frigate/api/event.py
@@ -724,13 +724,15 @@ def events_search(request: Request, params: EventsSearchQueryParams = Depends())
if (sort is None or sort == "relevance") and search_results:
processed_events.sort(key=lambda x: x.get("search_distance", float("inf")))
elif min_score is not None and max_score is not None and sort == "score_asc":
- processed_events.sort(key=lambda x: x["score"])
+ processed_events.sort(key=lambda x: x["data"]["score"])
elif min_score is not None and max_score is not None and sort == "score_desc":
- processed_events.sort(key=lambda x: x["score"], reverse=True)
+ processed_events.sort(key=lambda x: x["data"]["score"], reverse=True)
elif min_speed is not None and max_speed is not None and sort == "speed_asc":
- processed_events.sort(key=lambda x: x["average_estimated_speed"])
+ processed_events.sort(key=lambda x: x["data"]["average_estimated_speed"])
elif min_speed is not None and max_speed is not None and sort == "speed_desc":
- processed_events.sort(key=lambda x: x["average_estimated_speed"], reverse=True)
+ processed_events.sort(
+ key=lambda x: x["data"]["average_estimated_speed"], reverse=True
+ )
elif sort == "date_asc":
processed_events.sort(key=lambda x: x["start_time"])
else: