Skip to content

Commit

Permalink
Merge pull request #17176 from davelopez/23.1_fix_workflow_index_tota…
Browse files Browse the repository at this point in the history
…l_matches

[23.1] Fix workflow index total matches counting
  • Loading branch information
mvdbeek committed Dec 14, 2023
2 parents ac8cc32 + fa585e1 commit f6c06f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def name_filter(term):
term,
)
)
query = query.filter(model.StoredWorkflow.table.c.deleted == (true() if show_deleted else false()))
query = query.filter(model.StoredWorkflow.table.c.deleted == (true() if show_deleted else false())).distinct()
if include_total_count:
total_matches = query.count()
else:
Expand Down
27 changes: 27 additions & 0 deletions lib/galaxy_test/api/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,33 @@ def test_index_parameter_invalid_combinations(self):
self._assert_status_code_is(response, 400)
self._assert_error_code_is(response, error_codes.error_codes_by_name["USER_REQUEST_INVALID_PARAMETER"])

def test_index_total_matches(self):
with self._different_user("isolated.wf.user@test.email"):
my_workflow_id = self.workflow_populator.simple_workflow("mine_1")
self.workflow_populator.simple_workflow("mine_2")
my_email = self.dataset_populator.user_email()
with self._different_user():
their_shared_workflow_id = self.workflow_populator.simple_workflow("theirs_1")
self.workflow_populator.share_with_user(their_shared_workflow_id, my_email)
their_workflow_to_import_id = self.workflow_populator.simple_workflow("theirs_2", publish=True)
self.workflow_populator.set_tags(their_workflow_to_import_id, ["theirs_2", "test"])

import_response = self.__import_workflow(their_workflow_to_import_id)
self._assert_status_code_is(import_response, 200)
imported_wf_id = import_response.json()["id"]

# add tags to my workflows
self.workflow_populator.set_tags(my_workflow_id, ["mine_1", "test"])
self.workflow_populator.set_tags(imported_wf_id, ["imported", "test"])

# We should have 4 workflows now (2 mine, 1 shared with me, 1 imported)
expected_number_of_workflows = 4
workflows_response = self._get("workflows")
self._assert_status_code_is(workflows_response, 200)
assert workflows_response.headers["Total_matches"] == f"{expected_number_of_workflows}"
workflows = workflows_response.json()
assert len(workflows) == expected_number_of_workflows

def test_upload(self):
self.__test_upload(use_deprecated_route=False)

Expand Down

0 comments on commit f6c06f6

Please sign in to comment.