Skip to content

Commit

Permalink
Add get_with_filter method to repos
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Aug 16, 2023
1 parent 5c6c9ef commit 701962a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/galaxy/model/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 2 additions & 3 deletions lib/galaxy/webapps/galaxy/api/page_revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 701962a

Please sign in to comment.