mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Sub label filter fixes (#5602)
* Fix list access issue * Specifically include item when in list or individual only * Formatting * Sort sub labels to ensure consistent list
This commit is contained in:
parent
318240c14c
commit
17c26c9fa9
@ -322,7 +322,9 @@ def get_sub_labels():
|
|||||||
sub_labels.remove(None)
|
sub_labels.remove(None)
|
||||||
|
|
||||||
if split_joined:
|
if split_joined:
|
||||||
for label in sub_labels:
|
original_labels = sub_labels.copy()
|
||||||
|
|
||||||
|
for label in original_labels:
|
||||||
if "," in label:
|
if "," in label:
|
||||||
sub_labels.remove(label)
|
sub_labels.remove(label)
|
||||||
parts = label.split(",")
|
parts = label.split(",")
|
||||||
@ -331,6 +333,7 @@ def get_sub_labels():
|
|||||||
if not (part.strip()) in sub_labels:
|
if not (part.strip()) in sub_labels:
|
||||||
sub_labels.append(part.strip())
|
sub_labels.append(part.strip())
|
||||||
|
|
||||||
|
sub_labels.sort()
|
||||||
return jsonify(sub_labels)
|
return jsonify(sub_labels)
|
||||||
|
|
||||||
|
|
||||||
@ -638,7 +641,13 @@ def events():
|
|||||||
sub_label_clauses.append((Event.sub_label.is_null()))
|
sub_label_clauses.append((Event.sub_label.is_null()))
|
||||||
|
|
||||||
for label in filtered_sub_labels:
|
for label in filtered_sub_labels:
|
||||||
sub_label_clauses.append((Event.sub_label.cast("text") % f"*{label}*"))
|
sub_label_clauses.append(
|
||||||
|
(Event.sub_label.cast("text") == label)
|
||||||
|
) # include exact matches
|
||||||
|
|
||||||
|
# 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}*"))
|
||||||
|
|
||||||
sub_label_clause = reduce(operator.or_, sub_label_clauses)
|
sub_label_clause = reduce(operator.or_, sub_label_clauses)
|
||||||
clauses.append((sub_label_clause))
|
clauses.append((sub_label_clause))
|
||||||
|
Loading…
Reference in New Issue
Block a user