mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 23:59:10 +00:00
remove obsolete filename search
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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"],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user