From 807a487b25f52ddf484fdc685a96091a67742230 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Wed, 18 Oct 2023 17:59:47 +0100 Subject: [PATCH] Fix `index_repositories()` method Broken in commit 77df9c9a73e6efd5233ec881a555855e913b3aaf . --- lib/tool_shed/managers/repositories.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/tool_shed/managers/repositories.py b/lib/tool_shed/managers/repositories.py index 596aca642b0e..4886d2f81c37 100644 --- a/lib/tool_shed/managers/repositories.py +++ b/lib/tool_shed/managers/repositories.py @@ -20,6 +20,7 @@ false, select, ) +from sqlalchemy.orm import scoped_session from galaxy import web from galaxy.exceptions import ( @@ -254,7 +255,9 @@ def index_tool_ids(app: ToolShedApp, tool_ids: List[str]) -> Dict[str, Any]: def index_repositories(app: ToolShedApp, name: Optional[str], owner: Optional[str], deleted: bool): - return list(_get_repository_by_name_and_owner_and_deleted(app.model.context, name, owner, deleted, app.model.User)) + return list( + _get_repositories_by_name_and_owner_and_deleted(app.model.context, name, owner, deleted, app.model.User) + ) def can_manage_repo(trans: ProvidesUserContext, repository: Repository) -> bool: @@ -579,7 +582,7 @@ def upload_tar_and_set_metadata( return message -def _get_repository_by_name_and_owner(session, name, owner, user_model): +def _get_repository_by_name_and_owner(session: scoped_session, name: str, owner: str, user_model): stmt = ( select(Repository) .where(Repository.deprecated == false()) @@ -592,7 +595,9 @@ def _get_repository_by_name_and_owner(session, name, owner, user_model): return session.scalars(stmt).first() -def _get_repository_by_name_and_owner_and_deleted(session, name, owner, deleted, user_model): +def _get_repositories_by_name_and_owner_and_deleted( + session: scoped_session, name: Optional[str], owner: Optional[str], deleted: bool, user_model +): stmt = select(Repository).where(Repository.deprecated == false()).where(Repository.deleted == deleted) if owner is not None: stmt = stmt.where(user_model.username == owner) @@ -600,4 +605,4 @@ def _get_repository_by_name_and_owner_and_deleted(session, name, owner, deleted, if name is not None: stmt = stmt.where(Repository.name == name) stmt = stmt.order_by(Repository.name).limit(1) - return session.scalars(stmt).first() + return session.scalars(stmt)