Skip to content

Commit

Permalink
Add view, keys, limit and offset to get_histories
Browse files Browse the repository at this point in the history
  • Loading branch information
cat-bro committed Feb 29, 2024
1 parent 502dbc1 commit 4150d79
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bioblend/_tests/TestGalaxyHistories.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def test_get_histories(self):
)
assert len(old_histories) == 0

# Test detailed view: check for presence of "size" field
histories_detailed = self.gi.histories.get_histories(view="detailed")
assert "size" in histories_detailed[0]

# Test keys
histories_with_keys = self.gi.histories.get_histories(keys=["id", "user_id", "size"])
assert set([key for key in histories_with_keys[0]]) == set(["id", "user_id", "size"])

# TODO: check whether deleted history is returned correctly
# At the moment, get_histories() returns only not-deleted histories
# and get_histories(deleted=True) returns only deleted histories,
Expand Down
34 changes: 34 additions & 0 deletions bioblend/galaxy/histories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def _get_histories(
create_time_max: Optional[str] = None,
update_time_min: Optional[str] = None,
update_time_max: Optional[str] = None,
view: Optional[str] = "summary",
keys: Optional[List[str]] = None,
limit: Optional[int] = None,
offset: Optional[int] = None,
all: Optional[bool] = False,
) -> List[Dict[str, Any]]:
"""
Expand Down Expand Up @@ -124,6 +128,14 @@ def _get_histories(
params.setdefault("qv", []).append(update_time_max)
if all:
params["all"] = True
if view:
params["view"] = view
if keys:
params["keys"] = ",".join(keys)
if limit:
params["limit"] = limit
if offset:
params["offset"] = offset

url = "/".join((self._make_url(), "published")) if get_all_published else None
histories = self._get(url=url, params=params)
Expand All @@ -143,6 +155,10 @@ def get_histories(
create_time_max: Optional[str] = None,
update_time_min: Optional[str] = None,
update_time_max: Optional[str] = None,
view: Optional[str] = 'summary',
keys: Optional[List[str]] = None,
limit: Optional[int] = None,
offset: Optional[int] = None,
all: Optional[bool] = False,
) -> List[Dict[str, Any]]:
"""
Expand Down Expand Up @@ -187,6 +203,20 @@ def get_histories(
parameter works only on Galaxy 20.01 or later and can be specified
only if the user is a Galaxy admin.
:type view: str
:param view: Options are 'summary' or 'detailed'. This defaults to 'summary'.
Setting view to 'detailed' results in a larger number of fields returned.
:type keys: List[str]
:param keys: List of fields to return
:type limit: int
:param limit: How many items to return (upper bound).
:type offset: int
:param offset: skip the first ( offset - 1 ) items and begin returning
at the Nth item.
:rtype: list
:return: List of history dicts.
Expand All @@ -205,6 +235,10 @@ def get_histories(
get_all_published=False,
slug=slug,
all=all,
view=view,
keys=keys,
limit=limit,
offset=offset,
create_time_min=create_time_min,
create_time_max=create_time_max,
update_time_min=update_time_min,
Expand Down

0 comments on commit 4150d79

Please sign in to comment.