diff --git a/lib/galaxy/model/repositories/__init__.py b/lib/galaxy/model/repositories/__init__.py index 43d5c82c9092..48b7876031d5 100644 --- a/lib/galaxy/model/repositories/__init__.py +++ b/lib/galaxy/model/repositories/__init__.py @@ -29,3 +29,8 @@ def get(self, primary_key: Any) -> MappedType: def get_all(self) -> List: # type-ignore/SessionlessContext return self.session.scalars(select(self.model_class)).all() # type:ignore[union-attr] + + def get_with_filter(self, **kwd) -> List: + # type-ignore/SessionlessContext + stmt = select(self.model_class).filter_by(**kwd) + return self.session.scalars(stmt).all() # type:ignore[union-attr] diff --git a/lib/galaxy/webapps/galaxy/api/page_revisions.py b/lib/galaxy/webapps/galaxy/api/page_revisions.py index d913a995eb69..c9297781ce4f 100644 --- a/lib/galaxy/webapps/galaxy/api/page_revisions.py +++ b/lib/galaxy/webapps/galaxy/api/page_revisions.py @@ -3,10 +3,9 @@ """ import logging -from sqlalchemy import select - from galaxy.managers.base import get_object from galaxy.managers.pages import PageManager +from galaxy.model.repositories.page_revision import PageRevisionRepository from galaxy.web import expose_api from . import ( BaseGalaxyAPIController, @@ -32,7 +31,7 @@ def index(self, trans, page_id, **kwd): :returns: dictionaries containing different revisions of the page """ page = get_object(trans, page_id, "Page", check_ownership=False, check_accessible=True) - r = trans.sa_session.scalars(select(trans.app.model.PageRevision).filter_by(page_id=page.id)) + r = PageRevisionRepository(trans.sa_session).get_with_filter(page_id=page.id) out = [] for page in r: as_dict = self.encode_all_ids(trans, page.to_dict(), True)