remove obsolete filename search

This commit is contained in:
Jann Stute
2024-11-28 22:35:09 +01:00
parent 3d4b649903
commit 3ab8d6a871
3 changed files with 1 additions and 29 deletions

View File

@@ -74,8 +74,6 @@ class FilterState:
# these should be erased on update
# whole path
path: Path | str | None = None
# file name
name: str | None = None
# Abstract Syntax Tree Of the current Search Query
ast: Query = None
@@ -90,13 +88,11 @@ class FilterState:
if query is not None:
self.ast = Parser(query).parse()
else:
self.name = self.name and self.name.strip()
@property
def summary(self):
"""Show query summary."""
return self.name or self.path
return self.path
@property
def limit(self):

View File

@@ -447,14 +447,6 @@ class Library:
.outerjoin(TagAlias)
.where(SQLBoolExpressionBuilder().visit(search.ast))
)
elif search.name:
statement = select(Entry).where(
and_(
Entry.path.ilike(f"%{search.name}%"),
# dont match directory name (ie. has following slash)
~Entry.path.ilike(f"%{search.name}%/%"),
)
)
elif search.path:
search_str = str(search.path).replace("*", "%")
statement = statement.where(Entry.path.ilike(search_str))

View File

@@ -395,22 +395,6 @@ def test_remove_tag_from_field(library, entry_full):
assert removed_tag not in [tag.name for tag in field.tags]
@pytest.mark.parametrize(
["query_name", "has_result"],
[
("foo", 1), # filename substring
("bar", 1), # filename substring
("one", 0), # path, should not match
],
)
def test_search_file_name(library, query_name, has_result):
results = library.search_library(
FilterState(name=query_name),
)
assert results.total_count == has_result
@pytest.mark.parametrize(
["query_name", "has_result"],
[