Skip to content

Commit 030e3ed

Browse files
UbuntuUbuntu
authored andcommitted
Update
1 parent 2df9118 commit 030e3ed

9 files changed

Lines changed: 816 additions & 44 deletions

File tree

statsproj/openstack_stats/aggregator/templates/aggregator/detail.html

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
{% load staticfiles %}
1111
<script src="/static/jquery-1.9.1.js" type="text/javascript"></script>
1212
<script src="/static/jquery-ui.js" type="text/javascript"></script>
13+
<script src="/static/jquery-migrate-1.2.1.js" type="text/javascript"></script>
14+
<script src="/static/jquery.printElement.js" type="text/javascript"></script>
1315
<script src="/static/flot/jquery.flot.js" type="text/javascript"></script>
1416
<script src="/static/flot/jquery.flot.resize.js" type="text/javascript"></script>
1517
<script src="/static/flot/jquery.flot.time.js" type="text/javascript"></script>
@@ -41,6 +43,16 @@
4143
var {{ key|cut:"openstack/" }}Fail = {{ value.1|safe }};
4244
var {{ key|cut:"openstack/" }}Miss = {{ value.2|safe }};
4345
{% endfor %}
46+
47+
function printDiv()
48+
{
49+
var divToPrint=$("#main");
50+
newWin= window.open("");
51+
newWin.document.write(divToPrint.outerHTML);
52+
newWin.print();
53+
newWin.close();
54+
}
55+
4456
</script>
4557
<script type="text/javascript" src="/static/aggregator.js"></script>
4658
<link href="/static/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">
@@ -50,17 +62,41 @@
5062
<body>
5163
<div id="content">
5264
<div id="sidebar">
53-
<h2>{{ name }} Results</h2><br />
54-
<h2 id="total"></h2>
55-
<h2 id="success"></h2>
56-
<h2 id="failed"></h2>
57-
<h2 id="missed"></h2><br />
58-
<h2>Nova:</h3>
65+
<h3 style="text-align: center;">{{ name }} Results</h3><br />
66+
<table style="width: 100%;">
67+
<tr>
68+
<td></td>
69+
<td><strong>Tests</strong></td>
70+
<td><strong>Patchsets</strong></td>
71+
</tr>
72+
<tr>
73+
<td><strong>Total</strong></td>
74+
<td id="total"></td>
75+
<td id="totalps"></td>
76+
</tr>
77+
<tr>
78+
<td><strong>Success</strong></td>
79+
<td id="success"></td>
80+
<td id="successps"></td>
81+
</tr>
82+
<tr>
83+
<td><strong>Failed</strong></td>
84+
<td id="failed"></td>
85+
<td id="failedps"></td>
86+
</tr>
87+
<tr>
88+
<td><strong>Missed</strong></td>
89+
<td id="missed"></td>
90+
<td id="missedps"></td>
91+
</tr>
92+
</table><br />
93+
<h3>Nova:</h3>
5994
<div id="novaInfo"></div>
60-
<h2>Neutron:</h3>
95+
<h3>Neutron:</h3>
6196
<div id="neutronInfo"></div>
6297
<div id="links">
6398
<ul>
99+
<li><a id="print" href="javascript:void(0)">Print</a></li>
64100
<li><a href="/">Go Back</a></li>
65101
<li><a href="/accounts/logout">Logout</a></li>
66102
</ul>
@@ -76,17 +112,17 @@ <h2>Neutron:</h3>
76112
<label for="timeGranular">High Granularity</label>&nbsp;
77113
</form>
78114
<table class="graphtable">
79-
<tr>
80-
<td><h3 class="inline">Nova Tests</h3><div class="legend" id="novachartlegend"></div></td>
115+
<tr class="graphheader">
116+
<td colspan="2"><h3 class="inline">Nova Tests</h3><div class="legend" id="novachartlegend"></div></td>
81117
</tr>
82118
<tr>
83119
<td class="linechart" id="novachart"></td>
84120
<td class="piechart" id="novapiechart"></td>
85121
</tr>
86122
</table>
87123
<table class="graphtable">
88-
<tr>
89-
<td><h3 class="inline">Neutron Tests</h3><div class="legend" id="neutronchartlegend"></div></td>
124+
<tr class="graphheader">
125+
<td colspan="2"><h3 class="inline">Neutron Tests</h3><div class="legend" id="neutronchartlegend"></div></td>
90126
</tr>
91127
<tr>
92128
<td class="linechart" id="neutronchart"></td>

statsproj/openstack_stats/aggregator/templates/aggregator/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ <h1>Reports:</h1>
1414
<p> No data available!</p>
1515
{% endif %}
1616
<hr \>
17+
Copyright 2014 Gabriel Loewen
1718
<a style="float:right;" href="/accounts/logout">Logout</a><br />
1819
<a style="float:right;" href="/admin">Manage</a>
19-
<p>Copyright 2014 Gabriel Loewen</p>
2020
</div>
2121
</body>

statsproj/openstack_stats/aggregator/views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ def _getWorkerDetails(data, timeGranular, name, getTotals):
168168
ret[project] = [success,fail,miss]
169169

170170
if getTotals:
171-
totalSuccess = len(list(data.filter(success=True)))
172-
totalFail = len(list(data.filter(success=False,missed=False)))
173-
totalMiss = len(list(data.filter(missed=True)))
174-
ret["total"] = [totalSuccess, totalFail, totalMiss]
175-
171+
totalSuccess = data.filter(success=True)
172+
totalFail = data.filter(success=False,missed=False)
173+
totalMiss = data.filter(missed=True)
174+
ret["total"] = [len(list(totalSuccess)), len(list(totalFail)), len(list(totalMiss))]
175+
ret["patchset"] = [len(list(totalSuccess.values('cid','pid').distinct())), len(list(totalFail.values('cid','pid').distinct())), len(list(totalMiss.values('cid','pid').distinct()))]
176176
return ret
177177

178178
# Get details for the worker, both Nova and Neutron data

statsproj/openstack_stats/aggregatorService.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from time import sleep
99

1010
# Add headers to url request to masquerade as a JSON request
11-
def addheaders(req):
11+
def addHeaders(req):
1212
req.add_header('Content-Disposition', 'attachment')
1313
req.add_header('X-Content-Type-Options', 'nosniff')
1414
req.add_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
@@ -19,7 +19,7 @@ def addheaders(req):
1919
# Retrieve a list of details about a particular change ID
2020
def getGerritChangeRequest(cid):
2121
url = "https://review.openstack.org/changes/"+str(cid)+"/detail"
22-
req = addheaders(urllib2.Request(url))
22+
req = addHeaders(urllib2.Request(url))
2323
res = urllib2.urlopen(req)
2424
# ignore first line
2525
for line in res:
@@ -30,16 +30,19 @@ def getGerritChangeRequest(cid):
3030
def getChanges(project):
3131
# get all open and merged changes (ignoring abandoned)
3232
url = "https://review.openstack.org/changes/?q=status:open+project:"+project+"&q=status:merged+project:"+project
33-
req = addheaders(urllib2.Request(url))
33+
req = addHeaders(urllib2.Request(url))
3434
res = urllib2.urlopen(req)
35+
3536
# ignore first line
3637
for line in res:
3738
break
39+
3840
parser = ijson.parse(res)
3941
cids = []
4042
for prefix, event, value in parser:
4143
if "_number" in prefix:
4244
cids.append(value)
45+
4346
return cids
4447

4548
# Merge the change details for a worker/project into the DB
@@ -151,9 +154,9 @@ def foundIn(item, objects):
151154

152155
# Look for any jobs marked as missed that were later submitted
153156
# (i.e. fix up the false negatives)
154-
def fixup(project,worker, change):
155-
missed = change.objects.filter(project=project,worker=worker,missed=True)
156-
unMissed = change.objects.filter(project=project,worker=worker,missed=False)
157+
def fixup(project,worker):
158+
missed = Change.objects.filter(project=project,worker=worker,missed=True)
159+
unMissed = Change.objects.filter(project=project,worker=worker,missed=False)
157160
erroneous = [x for x in missed if foundIn(x,unMissed)]
158161
for c in erroneous:
159162
c.delete()
@@ -167,7 +170,7 @@ def fixup(project,worker, change):
167170
for source in sources:
168171
project = source.project
169172
worker = source.worker
170-
fixup(project, worker, Change)
173+
fixup(project, worker)
171174
threads.append(threading.Thread(target=workerThread, args=(project, worker)))
172175
# start threads
173176
for thread in threads:

statsproj/openstack_stats/static/aggregator.css

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ a:hover {
6969
background-color: #eee;
7070
padding-left: 5px;
7171
height: 100%;
72-
width: 200px;
72+
width: auto;
73+
max-width: 200px;
7374
max-width: 300px;
7475
float: left;
7576
padding-right: 5px;
7677
}
7778

79+
#sidebar td {
80+
padding-right: 5px;
81+
}
82+
7883
#main {
7984
height: auto;
80-
margin: 0;
81-
padding-left: 225px;
8285
padding-right: 10px;
86+
padding-left: 225px;
87+
margin: 0;
8388
}
8489

8590
#highlighted {
@@ -93,17 +98,18 @@ a:hover {
9398
}
9499

95100
#main form {
96-
padding-bottom: 20px;
101+
padding-bottom: 15px;
97102
}
98103

99104
#main h3, p {
100105
margin-left: 20px;
101106
}
102107

103108
.graphtable {
104-
width: 99%;
109+
border-spacing: 0;
110+
width: 100%;
105111
margin-bottom: 10px;
106-
padding-right: 5px;
112+
padding: 0;
107113
padding-bottom: 5px;
108114
min-width: 600px;
109115
background: #eee;
@@ -117,14 +123,14 @@ a:hover {
117123

118124
.piechart {
119125
display: table-cell;
120-
width: 250px;
126+
width: 220px;
121127
}
122128

123129
.linechart {
124130
box-sizing: border-box;
125131
display: inline-block;
126132
background-color: #eee;
127-
width: 98%;
133+
width: 100%;
128134
height: 250px;
129135
padding: 0;
130136
margin: 0;
@@ -172,3 +178,6 @@ a:hover {
172178
border-width: 13px;
173179
margin-top: -13px;
174180
}
181+
.graphheader {
182+
margin: 0;
183+
}

statsproj/openstack_stats/static/aggregator.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ function plotPie(div, data) {
134134
pie: {
135135
show: true,
136136
radius: 1,
137-
label: { radius: 3/4,
137+
stroke: { color: "#eee", width: 0.5 },
138+
label: { radius: 5/8,
138139
show: true,
139-
formatter: function(label, series){
140-
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
141-
},
140+
threshold: 0.01,
142141
}
143142
}
144143
},
@@ -242,16 +241,21 @@ function processData(project) {
242241
$(document).ready(function() {
243242
// Set up the datepicker divs
244243
$('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
245-
$('#total').html("Total: " + (totalSuccess+totalFail+totalMiss));
246-
$('#success').html("Success: " + totalSuccess);
247-
$('#failed').html("Failed: " + totalFail);
248-
$('#missed').html("Missed: " + totalMiss);
244+
245+
$('#total').html(totalSuccess+totalFail+totalMiss);
246+
$('#success').html(totalSuccess);
247+
$('#failed').html(totalFail);
248+
$('#missed').html(totalMiss);
249+
$('#totalps').html(patchsetSuccess+patchsetFail+patchsetMiss);
250+
$('#successps').html(patchsetSuccess);
251+
$('#failedps').html(patchsetFail);
252+
$('#missedps').html(patchsetMiss);
249253

250254
// Process the nova data and setup the nova charts
251255
var novaData = processData("nova");
252256
var novaSums = novaData[0];
253257
var totalNova = novaSums[0] + novaSums[1] + novaSums[2];
254-
$("#novaInfo").html("<h3>Total: " + totalNova + "</h3><h3>Success: " + novaSums[1] + "</h3><h3>Failed: " + novaSums[0] + "</h3><h3>Missed: " + novaSums[2] + "</h3>");
258+
$("#novaInfo").html("<strong>Total:</strong> " + totalNova + "<br /><strong>Success:</strong> " + novaSums[1] + "<br /><strong>Failed:</strong> " + novaSums[0] + "<br /><strong>Missed:</strong> " + novaSums[2]);
255259
if (totalNova > 0) {
256260
novaData = novaData[1];
257261
insertCheckBoxes("#novachartlegend", novaData, "nova");
@@ -270,7 +274,7 @@ $(document).ready(function() {
270274
var neutronData = processData("neutron");
271275
var neutronSums = neutronData[0];
272276
var totalNeutron = neutronSums[0] + neutronSums[1] + neutronSums[2];
273-
$("#neutronInfo").html("<h3>Total: " + totalNeutron + "</h3><h3>Success: " + neutronSums[1] + "</h3><h3>Failed: " + neutronSums[0] + "</h3><h3>Missed: " + neutronSums[2] + "</h3>");
277+
$("#neutronInfo").html("<strong>Total:</strong> " + totalNeutron + "<br /><strong>Success:</strong> " + neutronSums[1] + "<br /><strong>Failed:</strong> " + neutronSums[0] + "<br /><strong>Missed:</strong> " + neutronSums[2]);
274278
if (totalNeutron > 0) {
275279
neutronData = neutronData[1];
276280
insertCheckBoxes("#neutronchartlegend", neutronData, "neutron");
@@ -284,4 +288,18 @@ $(document).ready(function() {
284288
} else {
285289
$("#neutronchart").html("<p>No data available or has been unselected in data model.</p>").css({height: 'auto'});
286290
}
291+
$("#sidebar").css({"width": "auto", "max-width": "200px"});
292+
$("#sidebar").width("auto");
293+
$("#main").css("padding-left", $("#sidebar").width()+20);
294+
$("#print").click(function(e) {
295+
var win = window.open();
296+
win.document.write("<table>");
297+
win.document.write("<tr><td><h3>Nova</h3>"+$("#novaInfo").html()+"</td>");
298+
win.document.write("<td><img src=\""+$("#novachart").children()[0].toDataURL()+"\"/></td>");
299+
win.document.write("<td><img src=\""+$("#novapiechart").children()[0].toDataURL()+"\"/></td></tr>");
300+
win.document.write("<tr><td><h3>Neutron</h3>"+$("#neutronInfo").html()+"</td>");
301+
win.document.write("<td><img src=\""+$("#neutronchart").children()[0].toDataURL()+"\"/></td>");
302+
win.document.write("<td><img src=\""+$("#neutronpiechart").children()[0].toDataURL()+"\"/></td></tr>");
303+
win.document.write("</table>");
304+
});
287305
});

statsproj/openstack_stats/static/flot/jquery.flot.pie.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,11 @@ More detail and specific examples can be found in the included HTML file.
491491
var halfAngle = ((startAngle + slice.angle) + startAngle) / 2;
492492
var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);
493493
var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;
494-
494+
var label = slice.label + " " + Math.round(slice.percent) + "%";
495+
ctx.font="9px Verdana";
496+
ctx.fillStyle="#FFF";
497+
ctx.fillText(label, x-ctx.measureText(label).width/2, y);
498+
return true;
495499
var html = "<span class='pieLabel' id='pieLabel" + index + "' style='position:absolute;top:" + y + "px;left:" + x + "px;'>" + text + "</span>";
496500
target.append(html);
497501

@@ -782,7 +786,7 @@ More detail and specific examples can be found in the included HTML file.
782786
left: "auto"
783787
},
784788
stroke: {
785-
color: "#fff",
789+
color: "#444",
786790
width: 1
787791
},
788792
label: {

0 commit comments

Comments
 (0)