restore filter logic

This commit is contained in:
jpt 2025-05-03 14:41:00 -05:00
parent 968ae1d18a
commit 9e3dd591d6
2 changed files with 8 additions and 3 deletions

View File

@ -79,11 +79,16 @@ def get_things(
query = Thing.select().where(~Thing.deleted)
if search_text:
# TODO: which fields are searchable?
# TODO: which fields are searchable should by dynamic
query = query.where(fn.Lower(Thing.data['text']).contains(search_text.lower()))
for param, val in filters.items():
query = query.where(Thing.data[param] == val)
if val is not None:
# no _in query for JSON fields, so use OR
condition = False
for cond in val:
condition |= Thing.data[param] == cond
query = query.where(condition)
sort_expressions = _parse_sort_string(sort)
query = query.order_by(*sort_expressions)

View File

@ -51,7 +51,7 @@ class ThingTable(TableEditor):
def refresh_items(self):
items = get_things(
self.search_query,
filters={},# key: self._filters_to_list(key) for key in self._filters},
filters={key: self._filters_to_list(key) for key in self.filters},
sort=self.sort_string,
)
for item in items: