Skip to content

Commit

Permalink
Fix None filter for sub labels (#4981)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 committed Jan 10, 2023
1 parent e79eab7 commit d49359e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frigate/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,13 @@ def events():
# for example a sub label 'bob' would get events
# with sub labels 'bob' and 'bob, john'
sub_label_clauses = []
filtered_sub_labels = sub_labels.split(",")

for label in sub_labels.split(","):
if "None" in filtered_sub_labels:
filtered_sub_labels.remove("None")
sub_label_clauses.append((Event.sub_label.is_null()))

for label in filtered_sub_labels:
sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label}*"))

sub_label_clause = reduce(operator.or_, sub_label_clauses)
Expand All @@ -613,8 +618,13 @@ def events():
# use matching so events with multiple zones
# still match on a search where any zone matches
zone_clauses = []
filtered_zones = zones.split(",")

if "None" in filtered_zones:
filtered_zones.remove("None")
zone_clauses.append((Event.zones.length() == 0))

for zone in zones.split(","):
for zone in filtered_zones:
zone_clauses.append((Event.zones.cast("text") % f'*"{zone}"*'))

zone_clause = reduce(operator.or_, zone_clauses)
Expand Down

0 comments on commit d49359e

Please sign in to comment.