mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-28 19:06:19 -05:00
Replacing tag filtering with new tag_names_to_sub_select function which uses a single sub-select to filter FileGroups.
This commit is contained in:
parent
fedbbe31d7
commit
bc2ca0e512
5 changed files with 26 additions and 61 deletions
|
|
@ -20,7 +20,7 @@ from wrolpi.common import get_media_directory, logger, extract_domain, chdir, es
|
|||
from wrolpi.dates import now, Seconds
|
||||
from wrolpi.db import get_db_session, get_db_curs, optional_session
|
||||
from wrolpi.errors import UnknownArchive, InvalidOrderBy
|
||||
from wrolpi.files.lib import handle_file_group_search_results, tag_names_to_clauses
|
||||
from wrolpi.files.lib import handle_file_group_search_results, tag_names_to_sub_select
|
||||
from wrolpi.vars import DOCKERIZED, PYTEST
|
||||
|
||||
logger = logger.getChild(__name__)
|
||||
|
|
@ -416,10 +416,10 @@ def search_archives(search_str: str, domain: str, limit: int, offset: int, order
|
|||
raise InvalidOrderBy(f'Invalid order by: {order}')
|
||||
|
||||
if tag_names:
|
||||
where_, params_, join_ = tag_names_to_clauses(tag_names)
|
||||
wheres.append(where_)
|
||||
# Filter all FileGroups by those that have been tagged with the provided tag names.
|
||||
tags_stmt, params_ = tag_names_to_sub_select(tag_names)
|
||||
params.update(params_)
|
||||
joins.append(join_)
|
||||
wheres.append(f'fg.id = ANY({tags_stmt})')
|
||||
|
||||
if search_str and headline:
|
||||
headline = ''',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from modules.videos.models import Video
|
|||
from wrolpi.common import run_after, logger
|
||||
from wrolpi.db import get_db_session, optional_session
|
||||
from wrolpi.errors import UnknownVideo
|
||||
from wrolpi.files.lib import handle_file_group_search_results, tag_names_to_clauses
|
||||
from wrolpi.files.lib import handle_file_group_search_results, tag_names_to_sub_select
|
||||
from ..lib import save_channels_config
|
||||
|
||||
logger.getChild(__name__)
|
||||
|
|
@ -102,10 +102,10 @@ def search_videos(
|
|||
select_columns = 'fg.id, COUNT(*) OVER() AS total'
|
||||
|
||||
if tag_names:
|
||||
where_, params_, join_ = tag_names_to_clauses(tag_names)
|
||||
wheres.append(where_)
|
||||
# Filter all FileGroups by those that have been tagged with the provided tag names.
|
||||
tags_stmt, params_ = tag_names_to_sub_select(tag_names)
|
||||
params.update(params_)
|
||||
joins.append(join_)
|
||||
wheres.append(f'fg.id = ANY({tags_stmt})')
|
||||
|
||||
if search_str and headline:
|
||||
headline = ''',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue