Sort executions and tasks by time
Closes-bug: #1391118 Change-Id: I8417c3679350c40f73faff22bd82d9549845fe25
This commit is contained in:
parent
b1fe6086cb
commit
762ac34aa2
@ -15,7 +15,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import operator
|
||||
|
||||
from pecan import rest
|
||||
from wsme import types as wtypes
|
||||
@ -140,11 +139,8 @@ class TasksController(rest.RestController):
|
||||
"""Return all tasks within the execution."""
|
||||
LOG.debug("Fetch tasks")
|
||||
|
||||
db_models = [task.to_dict() for task in db_api.get_tasks()]
|
||||
|
||||
tasks = sorted(db_models, key=operator.itemgetter('created_at'))
|
||||
|
||||
tasks = [Task.from_dict(task) for task in tasks]
|
||||
tasks = [Task.from_dict(db_model.to_dict())
|
||||
for db_model in db_api.get_tasks()]
|
||||
|
||||
return Tasks(tasks=tasks)
|
||||
|
||||
|
@ -104,13 +104,13 @@ def _get_collection_sorted_by_name(model, **kwargs):
|
||||
return proj.union(public).order_by(model.name).all()
|
||||
|
||||
|
||||
def _get_collection(model, **kwargs):
|
||||
def _get_collection_sorted_by_time(model, **kwargs):
|
||||
query = b.model_query(model)
|
||||
|
||||
return query.filter_by(
|
||||
project_id=db_base.get_project_id(),
|
||||
**kwargs
|
||||
).all()
|
||||
).order_by(model.created_at).all()
|
||||
|
||||
|
||||
def _get_db_object_by_name(model, name):
|
||||
@ -368,7 +368,7 @@ def delete_executions(**kwargs):
|
||||
|
||||
|
||||
def _get_executions(**kwargs):
|
||||
return _get_collection(models.Execution, **kwargs)
|
||||
return _get_collection_sorted_by_time(models.Execution, **kwargs)
|
||||
|
||||
|
||||
def _get_execution(id):
|
||||
@ -454,7 +454,7 @@ def _get_task(id):
|
||||
|
||||
|
||||
def _get_tasks(**kwargs):
|
||||
return _get_collection(models.Task, **kwargs)
|
||||
return _get_collection_sorted_by_time(models.Task, **kwargs)
|
||||
|
||||
|
||||
# Delayed calls.
|
||||
|
Loading…
Reference in New Issue
Block a user