mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-09 08:37:37 +03:00
make sub label query for events API endpoints case insensitive
This commit is contained in:
parent
dcc8744399
commit
1a708a3748
@ -407,7 +407,7 @@ async def _execute_search_objects(
|
||||
query_params = EventsQueryParams(
|
||||
cameras=arguments.get("camera", "all"),
|
||||
labels=arguments.get("label", "all"),
|
||||
sub_labels=arguments.get("sub_label", "all").lower(),
|
||||
sub_labels=arguments.get("sub_label", "all"), # case-insensitive on the backend
|
||||
zones=zones,
|
||||
zone=zones,
|
||||
after=after,
|
||||
|
||||
@ -199,13 +199,18 @@ def events(
|
||||
sub_label_clauses.append((Event.sub_label.is_null()))
|
||||
|
||||
for label in filtered_sub_labels:
|
||||
lowered = label.lower()
|
||||
sub_label_clauses.append(
|
||||
(Event.sub_label.cast("text") == label)
|
||||
) # include exact matches
|
||||
(fn.LOWER(Event.sub_label.cast("text")) == lowered)
|
||||
) # include exact matches (case-insensitive)
|
||||
|
||||
# include this label when part of a list
|
||||
sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label},*"))
|
||||
sub_label_clauses.append((Event.sub_label.cast("text") % f"*, {label}*"))
|
||||
# include this label when part of a list (LIKE is case-insensitive in sqlite for ASCII)
|
||||
sub_label_clauses.append(
|
||||
(fn.LOWER(Event.sub_label.cast("text")) % f"*{lowered},*")
|
||||
)
|
||||
sub_label_clauses.append(
|
||||
(fn.LOWER(Event.sub_label.cast("text")) % f"*, {lowered}*")
|
||||
)
|
||||
|
||||
sub_label_clause = reduce(operator.or_, sub_label_clauses)
|
||||
clauses.append((sub_label_clause))
|
||||
@ -609,13 +614,18 @@ def events_search(
|
||||
sub_label_clauses.append((Event.sub_label.is_null()))
|
||||
|
||||
for label in filtered_sub_labels:
|
||||
lowered = label.lower()
|
||||
sub_label_clauses.append(
|
||||
(Event.sub_label.cast("text") == label)
|
||||
) # include exact matches
|
||||
(fn.LOWER(Event.sub_label.cast("text")) == lowered)
|
||||
) # include exact matches (case-insensitive)
|
||||
|
||||
# include this label when part of a list
|
||||
sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label},*"))
|
||||
sub_label_clauses.append((Event.sub_label.cast("text") % f"*, {label}*"))
|
||||
# include this label when part of a list (LIKE is case-insensitive in sqlite for ASCII)
|
||||
sub_label_clauses.append(
|
||||
(fn.LOWER(Event.sub_label.cast("text")) % f"*{lowered},*")
|
||||
)
|
||||
sub_label_clauses.append(
|
||||
(fn.LOWER(Event.sub_label.cast("text")) % f"*, {lowered}*")
|
||||
)
|
||||
|
||||
event_filters.append((reduce(operator.or_, sub_label_clauses)))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user