mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-01-31 23:29:10 +00:00
fix: remove unnecessary joins in search
This commit is contained in:
@@ -585,19 +585,15 @@ class Library:
|
||||
elif extensions:
|
||||
statement = statement.where(Entry.suffix.in_(extensions))
|
||||
|
||||
statement = statement.options(
|
||||
selectinload(Entry.text_fields),
|
||||
selectinload(Entry.datetime_fields),
|
||||
selectinload(Entry.tags).options(
|
||||
selectinload(Tag.aliases), selectinload(Tag.parent_tags)
|
||||
),
|
||||
)
|
||||
|
||||
statement = statement.distinct(Entry.id)
|
||||
|
||||
query_count = select(func.count()).select_from(statement.alias("entries"))
|
||||
count_all: int = session.execute(query_count).scalar()
|
||||
|
||||
statement = statement.limit(search.limit).offset(search.offset)
|
||||
|
||||
logger.info(
|
||||
|
||||
@@ -101,25 +101,6 @@ def test_tag_self_parent(library, generate_tag):
|
||||
assert len(tag.parent_ids) == 0
|
||||
|
||||
|
||||
def test_library_search(library, generate_tag, entry_full):
|
||||
assert library.entries_count == 2
|
||||
tag = list(entry_full.tags)[0]
|
||||
|
||||
results = library.search_library(
|
||||
FilterState.from_tag_name(tag.name),
|
||||
)
|
||||
|
||||
assert results.total_count == 1
|
||||
assert len(results) == 1
|
||||
|
||||
entry = results[0]
|
||||
assert {x.name for x in entry.tags} == {
|
||||
"foo",
|
||||
}
|
||||
|
||||
assert entry.tags
|
||||
|
||||
|
||||
def test_tag_search(library):
|
||||
tag = library.tags[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user