From b2f8de082c3ae41eb44e6ccdc283849b64d0b0f2 Mon Sep 17 00:00:00 2001 From: Ravi Chintakunta Date: Fri, 10 Jan 2014 16:43:24 -0500 Subject: [PATCH] toaster: All Tasks Feature with sorting and filtering - Fixed the all tasks view and template to match the UI design and use the new basetable code. - Added a method to views to add sort order icon to the view context. - Default sort order when the page is loaded is displayed with the sort icon - Filtering of columns Signed-off-by: Ravi Chintakunta --- lib/toaster/toastergui/templates/task.html | 74 ------------ lib/toaster/toastergui/templates/tasks.html | 67 +++++++++++ lib/toaster/toastergui/views.py | 124 +++++++++++++++++++- 3 files changed, 185 insertions(+), 80 deletions(-) delete mode 100644 lib/toaster/toastergui/templates/task.html create mode 100644 lib/toaster/toastergui/templates/tasks.html diff --git a/lib/toaster/toastergui/templates/task.html b/lib/toaster/toastergui/templates/task.html deleted file mode 100644 index 6af2c512770..00000000000 --- a/lib/toaster/toastergui/templates/task.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends "basebuildpage.html" %} - -{% block localbreadcrumb %} -
  • Tasks
  • -{% endblock %} - -{% block buildinfomain %} -{% include "basetable_top.html" %} - - - {% if not objects %} -

    No tasks were executed in this build!

    - {% else %} - - - Order - Task - Recipe Version - Task Type - Checksum - Outcome - Message - Time - CPU usage - Disk I/O - Script type - Filesystem - Depends - - - {% for task in objects %} - - - {{task.order}} - - {{task.recipe.name}}.{{task.task_name}} - {{task.recipe.version}} - - {% if task.task_executed %} - Executed - {% else %} - Prebuilt - {% endif %} - - {{task.sstate_checksum}} - {{task.get_outcome_display}}{% if task.provider %}
    (by {{task.provider.recipe.name}}.{{task.provider.task_name}}){% endif %} -

    {{task.message}} - {{task.elapsed_time}} - {{task.cpu_usage}} - {{task.disk_io}} - {{task.get_script_type_display}} - - - - - -
    Recipe{{task.recipe.file_path}}
    Source{{task.file_name}}:{{task.line_number}}
    Workdir{{task.work_directory}}
    Log{{task.logfile}}
    - - -

    - {% for tt in task.task_dependencies_task.all %} - - {{tt.depends_on.recipe.name}}.{{tt.depends_on.task_name}}
    - {% endfor %} -
    - - - - {% endfor %} - - {% endif %} - -{% include "basetable_bottom.html" %} -{% endblock %} diff --git a/lib/toaster/toastergui/templates/tasks.html b/lib/toaster/toastergui/templates/tasks.html new file mode 100644 index 00000000000..6831f106c0b --- /dev/null +++ b/lib/toaster/toastergui/templates/tasks.html @@ -0,0 +1,67 @@ +{% extends "basebuildpage.html" %} +{% load projecttags %} +{% block localbreadcrumb %} +
  • All tasks
  • +{% endblock %} + +{% block buildinfomain %} +
    + +{% include "basetable_top.html" %} + + + {% if not objects %} +

    No tasks were executed in this build!

    + {% else %} + {% for task in objects %} + + + {{task.order}} + + + {{task.recipe.name}} + + + {{task.recipe.version}} + + + {{task.task_name}} + + + + {% if task.task_executed %} + Executed + {% else %} + Not executed + {% endif %} + + + + {{task.get_outcome_display}} + + + {{task.get_sstate_result_display|format_none_and_zero}} + + + {{task.elapsed_time|format_none_and_zero}} + + + {{task.cpu_usage|format_none_and_zero}} + + + {{task.disk_io|format_none_and_zero}} + + + {{task.logfile}} + + + + {% endfor %} + + {% endif %} + +{% include "basetable_bottom.html" %} +
    +{% endblock %} diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py index 1604bb6bc43..ab8b938cdd9 100644 --- a/lib/toaster/toastergui/views.py +++ b/lib/toaster/toastergui/views.py @@ -109,6 +109,14 @@ def _get_toggle_order(request, orderkey, reverse = False): else: return "%s:-" % orderkey if request.GET.get('orderby', "") == "%s:+" % orderkey else "%s:+" % orderkey +def _get_toggle_order_icon(request, orderkey): + if request.GET.get('orderby', "") == "%s:+"%orderkey: + return "down" + elif request.GET.get('orderby', "") == "%s:-"%orderkey: + return "up" + else: + return None + # we check that the input comes in a valid form that we can recognize def _validate_input(input, model): @@ -390,8 +398,8 @@ def _find_task_provider(task): return None def tasks(request, build_id): - template = 'task.html' - mandatory_parameters = { 'count': 100, 'page' : 1}; + template = 'tasks.html' + mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'order:+'}; retval = _verify_parameters( request.GET, mandatory_parameters ) if retval: return _redirect_parameters( 'tasks', request.GET, mandatory_parameters, build_id = build_id) @@ -401,11 +409,115 @@ def tasks(request, build_id): tasks = _build_page_range(Paginator(queryset, request.GET.get('count', 100)),request.GET.get('page', 1)) - for t in tasks: - if t.outcome == Task.OUTCOME_COVERED: - t.provider = _find_task_provider(t) +# Per Belen - do not show the covering task +# for t in tasks: +# if t.outcome == Task.OUTCOME_COVERED: +# t.provider = _find_task_provider(t) + + context = { 'objectname': 'tasks', + 'build': Build.objects.filter(pk=build_id)[0], + 'objects': tasks, + 'tablecols':[ + { + 'name':'Order', + 'qhelp':'The running sequence of each task in the build', + 'orderfield': _get_toggle_order(request, "order"), + 'ordericon':_get_toggle_order_icon(request, "order"), + }, + { + 'name':'Recipe', + 'qhelp':'The name of the recipe to which each task applies', +# 'orderfield': _get_toggle_order(request, "recipe"), + 'ordericon':_get_toggle_order_icon(request, "recipe"), + }, + { + 'name':'Recipe version', + 'qhelp':'The version of the recipe to which each task applies', + 'clclass': 'recipe_version', + 'hidden' : 1, + }, + { + 'name':'Task', + 'qhelp':'The name of the task', + 'orderfield': _get_toggle_order(request, "task_name"), + 'ordericon':_get_toggle_order_icon(request, "task_name"), + }, + { + 'name':'Executed', + 'qhelp':"This value tells you if a task had to run in order to generate the task output (executed), or if the output was provided by another task and therefore the task didn't need to run (not executed)", + 'orderfield': _get_toggle_order(request, "task_executed"), + 'ordericon':_get_toggle_order_icon(request, "task_executed"), + 'filter' : { + 'class' : 'executed', + 'label': 'Show:', + 'options' : [ + ('Executed Tasks', 'task_executed:1'), + ('Not Executed Tasks', 'task_executed:0'), + ] + } + + }, + { + 'name':'Outcome', + 'qhelp':'This column tells you if executed tasks succeeded, failed or restored output from the sstate-cache directory or mirrors. It also tells you why not executed tasks did not need to run', + 'orderfield': _get_toggle_order(request, "outcome"), + 'ordericon':_get_toggle_order_icon(request, "outcome"), + 'filter' : { + 'class' : 'outcome', + 'label': 'Show:', + 'options' : [ + ('Succeeded Tasks', 'outcome:%d'%Task.OUTCOME_SUCCESS), + ('Failed Tasks', 'outcome:%d'%Task.OUTCOME_FAILED), + ('Cached Tasks', 'outcome:%d'%Task.OUTCOME_CACHED), + ('Prebuilt Tasks', 'outcome:%d'%Task.OUTCOME_PREBUILT), + ('Covered Tasks', 'outcome:%d'%Task.OUTCOME_COVERED), + ('Empty Tasks', 'outcome:%d'%Task.OUTCOME_NA), + ] + } - context = {'build': Build.objects.filter(pk=build_id)[0], 'objects': tasks} + }, + { + 'name':'Cache attempt', + 'qhelp':'This column tells you if a task tried to restore output from the sstate-cache directory or mirrors, and what was the result: Succeeded, Failed or File not in cache', + 'orderfield': _get_toggle_order(request, "sstate_result"), + 'ordericon':_get_toggle_order_icon(request, "sstate_result"), + 'filter' : { + 'class' : 'cache_attempt', + 'label': 'Show:', + 'options' : [ + ('Tasks with cache attempts', 'sstate_result:%d'%Task.SSTATE_NA), + ("Tasks with 'File not in cache' attempts", 'sstate_result:%d'%Task.SSTATE_MISS), + ("Tasks with 'Failed' cache attempts", 'sstate_result:%d'%Task.SSTATE_FAILED), + ("Tasks with 'Succeeded' cache attempts", 'sstate_result:%d'%Task.SSTATE_RESTORED), + ] + } + + }, + { + 'name':'Time (secs)', + 'qhelp':'How long it took the task to finish, expressed in seconds', + 'clclass': 'time_taken', + 'hidden' : 1, + }, + { + 'name':'CPU usage', + 'qhelp':'Task CPU utilisation, expressed as a percentage', + 'clclass': 'cpu_used', + 'hidden' : 1, + }, + { + 'name':'Disk I/O (ms)', + 'qhelp':'Number of miliseconds the task spent doing disk input and output', + 'clclass': 'disk_io', + 'hidden' : 1, + }, + { + 'name':'Log', + 'qhelp':'The location in disk of the task log file', + 'clclass': 'task_log', + 'hidden' : 1, + }, + ]} return render(request, template, context) -- 2.47.3