From 1dbb3f25251b6acd8c185d768750803e192a9a31 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Thu, 14 Jul 2016 16:51:22 +0700 Subject: [PATCH] Fixing filtering in task controller * _get_task_resources_with_results() was given one extra parameter "wf_ex_id" whereas it was already passed in **filters. It was all wrong as we just need to pass "workflow_execution_id" in filters * There was also wrong "id" filter which gave empty db list every time TODO: * Add tests to check filtering in controllers Change-Id: Ibce9a40bc63ed63173b91e5f03cf71125537cf73 --- mistral/api/controllers/v2/task.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mistral/api/controllers/v2/task.py b/mistral/api/controllers/v2/task.py index 9e648b9c..be6a131b 100644 --- a/mistral/api/controllers/v2/task.py +++ b/mistral/api/controllers/v2/task.py @@ -109,7 +109,7 @@ def _get_task_resource_with_result(task_ex): return task -def _get_task_resources_with_results(wf_ex_id=None, marker=None, limit=None, +def _get_task_resources_with_results(marker=None, limit=None, sort_keys='created_at', sort_dirs='asc', fields='', **filters): """Return all tasks within the execution. @@ -133,9 +133,6 @@ def _get_task_resources_with_results(wf_ex_id=None, marker=None, limit=None, constructing 'next' link. :param filters: Optional. A list of filters to apply to the result. """ - if wf_ex_id: - filters['workflow_execution_id'] = wf_ex_id - return rest_utils.get_all( Tasks, Task, @@ -357,9 +354,8 @@ class ExecutionTasksController(rest.RestController): acl.enforce('tasks:list', context.ctx()) filters = rest_utils.filters_to_dict( - wf_ex_id=workflow_execution_id, + workflow_execution_id=workflow_execution_id, created_at=created_at, - id=id, workflow_name=workflow_name, workflow_id=workflow_id, state=state, @@ -379,7 +375,6 @@ class ExecutionTasksController(rest.RestController): filters) return _get_task_resources_with_results( - wf_ex_id=workflow_execution_id, marker=marker, limit=limit, sort_keys=sort_keys,