diff --git a/stackviz/static/css/upstream_run.css b/stackviz/static/css/upstream_run.css new file mode 100644 index 00000000..019a3a34 --- /dev/null +++ b/stackviz/static/css/upstream_run.css @@ -0,0 +1,3 @@ +.highlight { + font-weight: bold; +} \ No newline at end of file diff --git a/stackviz/static/js/upstream_run.js b/stackviz/static/js/upstream_run.js index 0c89f293..21769338 100644 --- a/stackviz/static/js/upstream_run.js +++ b/stackviz/static/js/upstream_run.js @@ -18,22 +18,67 @@ window.addEventListener('load', function() { + //default panel display $("#runs-panel").hide(); $("#gerrit-panel").show(); + $("#run-metadata-panel").hide(); + + //dict containing all run_metadata objects, keyed by run_id + var RUN_METADATA = {}; + + //sets the run metdata of the associated run in the proper div + function show_run_metadata(id) { + $("#run-metadata-table").html("KeyValue"); + var meta = RUN_METADATA[id]; + for (var i in meta) { + var obj = meta[i]; + var row = $("" + obj['key'] + "" + + "" + obj['value'] + ""); + $("#run-metadata-table").append(row); + } + } + + //run_metadata will be queried from subunit2sql when given run_id + function get_run_metadata(request, run_id) { + $.getJSON((request),function(metadata) { + RUN_METADATA[run_id]=metadata; + }); + } + + //Takes a list of runs and creates a pretty div for each function display_runs(data) { $("#runs-panel").show(); + $("#runs-panel").append(""); + for (var i in data) { - var run_obj = data[i] - var div = $("
"); - $(div.append("" + run_obj['artifacts'] + "\n")); - $("#runs-panel").append(div); + var run_obj = data[i]; + //get run_metadata + var request = 'upstream_api_run_id_' + run_obj['id'] + '.json'; + get_run_metadata(request, run_obj['id']); + + var li = $("
  • "); + //on mouseover, show the run_metadata for this run object (li) + $(li).hover( + function () { + $(this).addClass("highlight"); + show_run_metadata($(this).attr("value")); + }, + function () { + $(this).removeClass("highlight"); + } + ); + + $(li.append("" + run_obj['artifacts'] + "\n")); + $("#runs-list").append(li); $("#runs-panel-heading").html("Displaying " + i + " Runs"); } + $("#run-metadata-panel").show(); } + $('#gerrit-id').keypress(function (e) { if (e.which == 13) { $( "#gerrit-id-button" ).click(); @@ -41,6 +86,8 @@ window.addEventListener('load', function() { } }); + + //click triggers the api call that returns the run data $('#gerrit-id-button').click(function() { var request = 'upstream_api_changeid_'+$("#gerrit-id").val()+'.json'; $("#runs-panel").append("{% endblock %} +{% block head-extra %} + + +{% endblock %} {% block body %} @@ -17,7 +20,7 @@
    -
    +
    Analyze Run
    @@ -29,6 +32,16 @@
    +
    +
    +
    Run Metadata
    +
    +
    +
    +
    +
    +
    +
    diff --git a/stackviz/templates/upstream/test.html b/stackviz/templates/upstream/test.html index bc8deeb8..89bc6c15 100644 --- a/stackviz/templates/upstream/test.html +++ b/stackviz/templates/upstream/test.html @@ -11,4 +11,20 @@
    +
    +
    +
    +
    Compare Tests
    +
    +
    +
    Test
    +
    +
    +
    Avg
    +
    +
    +
    +
    +
    + {% endblock %} \ No newline at end of file diff --git a/stackviz/views/upstream/api.py b/stackviz/views/upstream/api.py index f7a4fcf7..ed5efc49 100644 --- a/stackviz/views/upstream/api.py +++ b/stackviz/views/upstream/api.py @@ -31,10 +31,7 @@ def _get_runs(change_id): engine = create_engine('mysql://query:query@logstash.openstack.org' + ':3306/subunit2sql') - Session = sessionmaker(bind=engine) - - # create a Session session = Session() list_of_runs = api.get_runs_by_key_value(key="build_change", @@ -47,8 +44,33 @@ def _get_runs(change_id): return ret_list +def _get_metadata(run_id): + """Returns a dict of run_metadata objects associated with a run_id + + :param run_id: + :return: + """ + + engine = create_engine('mysql://query:query@logstash.openstack.org' + + ':3306/subunit2sql') + Session = sessionmaker(bind=engine) + session = Session() + + metadata = api.get_run_metadata(run_id,session=session) + ret_list = [] + + for meta in metadata: + ret_list.append(meta.to_dict()) + + return ret_list + class GerritURLEndpoint(Endpoint): def get(self, request, change_id): return _get_runs(change_id) + +class RunMetadataEndpoint(Endpoint): + + def get(self, request, run_id): + return _get_metadata(run_id) diff --git a/stackviz/views/upstream/urls.py b/stackviz/views/upstream/urls.py index ceecabd9..3320a303 100644 --- a/stackviz/views/upstream/urls.py +++ b/stackviz/views/upstream/urls.py @@ -19,6 +19,7 @@ from run import RunView from test import TestView from api import GerritURLEndpoint +from api import RunMetadataEndpoint urlpatterns = patterns('', url(r'^run.html$', @@ -31,5 +32,9 @@ urlpatterns = patterns('', url(r'^api_changeid_(?P\d+).json$', GerritURLEndpoint.as_view(), - name='gerrit_url') + name='gerrit_url'), + + url(r'^api_run_id_(?P[a-zA-Z0-9!$* \t\r\n\-]+).json$', + RunMetadataEndpoint.as_view(), + name='run_metadata_url') )