diff mbox

[Branch,~linaro-validation/lava-dashboard/trunk] Rev 410: Introduce new plot-by-measurements on Image Reports page. Reviewed by tyler-baker.

Message ID 20130702093113.30798.4411.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Stevan Radakovic July 2, 2013, 9:31 a.m. UTC
Merge authors:
  Stevan Radaković (stevanr)
Related merge proposals:
  https://code.launchpad.net/~stevanr/lava-dashboard/fix-1196477/+merge/172357
  proposed by: Stevan Radaković (stevanr)
  review: Approve - Tyler Baker (tyler-baker)
------------------------------------------------------------
revno: 410 [merge]
committer: Stevan Radakovic <stevan.radakovic@linaro.org>
branch nick: trunk
timestamp: Tue 2013-07-02 11:30:04 +0200
message:
  Introduce new plot-by-measurements on Image Reports page. Reviewed by tyler-baker.
modified:
  dashboard_app/static/dashboard_app/js/image-report.js
  dashboard_app/templates/dashboard_app/image-report.html
  dashboard_app/views/images.py


--
lp:lava-dashboard
https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk

You are subscribed to branch lp:lava-dashboard.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'dashboard_app/static/dashboard_app/js/image-report.js'
--- dashboard_app/static/dashboard_app/js/image-report.js	2013-06-19 08:20:44 +0000
+++ dashboard_app/static/dashboard_app/js/image-report.js	2013-07-01 15:49:15 +0000
@@ -236,8 +236,10 @@ 
     if ($.jStorage.get(prefix + "_graph_type")) {
 	if ($.jStorage.get(prefix + "_graph_type") == "number") {
 	    $('input:radio[name=graph_type][value="number"]').attr("checked", true);
-	} else {
+	} else if ($.jStorage.get(prefix + "_graph_type") == "percentage") {
 	    $('input:radio[name=graph_type][value="percentage"]').attr("checked", true);
+	} else { // measurements
+	    $('input:radio[name=graph_type][value="measurements"]').attr("checked", true);
 	}
     }
 }
@@ -261,8 +263,10 @@ 
 	if (parameters[iter][0] == "graph_type" && parameters[iter][1] != "") {
 	    if (parameters[iter][1] == "number") {
 		$('input:radio[name=graph_type][value="number"]').attr("checked", true);
-	    } else {
+	    } else if (parameters[iter][1] == "percentage") {
 		$('input:radio[name=graph_type][value="percentage"]').attr("checked", true);
+	    } else { // measurements
+		$('input:radio[name=graph_type][value="measurements"]').attr("checked", true);
 	    }
 	}
     }
@@ -280,6 +284,7 @@ 
     // Get the plot data.
 
     data = [];
+    units = "";
     for (test in table_data) {
 
 	if ($("#test_select").val().indexOf(test) >= 0) {
@@ -292,12 +297,17 @@ 
 		    if (row[iter]["cls"]) {
 			if ($('input:radio[name=graph_type]:checked').val() == "number") {
 			    row_data.push([iter, row[iter]["passes"]]); 
-			} else {
+			} else if ($('input:radio[name=graph_type]:checked').val() == "percentage") {
 			    if (isNaN(row[iter]["passes"]/row[iter]["total"])) {
 				row_data.push([iter, 0]);
 			    } else {
 				row_data.push([iter, 100*row[iter]["passes"]/row[iter]["total"]]);
 			    }
+			} else { // measurements
+			    if (row[iter]["measurements"] && row[iter]["measurements"].length != 0) {
+				row_data.push([iter, row[iter]["measurements"][0]["measurement"]]);
+				units = row[iter]["measurements"][0]["units"];
+			    }
 			}
 		    }
 		}
@@ -366,6 +376,14 @@ 
 	options["yaxis"]["min"] = 0;
     }
 
+    if (units != "") {
+	options["legend"]["labelFormatter"] = function(label, series) {
+	    if (label.length > 20) {
+		return label.substring(0,20) + "...";
+	    }
+	    return label + " (" + units + ")";
+	}
+    }
 
     $.plot($("#outer-container #inner-container"), data, options); 
 }

=== modified file 'dashboard_app/templates/dashboard_app/image-report.html'
--- dashboard_app/templates/dashboard_app/image-report.html	2013-06-18 13:12:18 +0000
+++ dashboard_app/templates/dashboard_app/image-report.html	2013-07-01 15:49:15 +0000
@@ -76,6 +76,9 @@ 
     <input type="radio" name="graph_type" onclick='update_table(columns, chart_data, test_names)' value="number">
     By pass/fail test numbers
     </input>
+    <input type="radio" name="graph_type" onclick='update_table(columns, chart_data, test_names)' value="measurements">
+    By measurements
+    </input>
   </div>
 </div>
 

=== modified file 'dashboard_app/views/images.py'
--- dashboard_app/views/images.py	2013-05-30 07:45:34 +0000
+++ dashboard_app/views/images.py	2013-07-01 15:49:15 +0000
@@ -73,7 +73,7 @@ 
 
     image = Image.objects.get(name=name)
     filter_data = image.filter.as_data()
-    matches = evaluate_filter(request.user, filter_data, prefetch_related=['launchpad_bugs'])[:50]
+    matches = evaluate_filter(request.user, filter_data, prefetch_related=['launchpad_bugs', 'test_results'])[:50]
 
     build_number_to_cols = {}
 
@@ -88,6 +88,13 @@ 
             else:
                     cls = 'present fail'
             bug_ids = sorted([b.bug_id for b in test_run.launchpad_bugs.all()])
+
+            measurements = [{'item': str(item.test_case),
+                             'measurement': str(item.measurement),
+                             'units': str(item.units)
+                             }
+                            for item in test_run.test_results.all()]
+
             test_run_data = dict(
                 present=True,
                 cls=cls,
@@ -96,6 +103,7 @@ 
                 total=denorm.count_pass + denorm.count_fail,
                 link=test_run.get_permalink(),
                 bug_ids=bug_ids,
+                measurements=measurements,                
                 )
             if (match.tag, test_run.bundle.uploaded_on) not in build_number_to_cols:
                 build_number_to_cols[(match.tag, test_run.bundle.uploaded_on)] = {