SomeFire commented on a change in pull request #9: IGNITE-9541 Add the comparison for two general statistics "RunAll" for master in the date interval URL: https://github.com/apache/ignite-teamcity-bot/pull/9#discussion_r218104124
########## File path: ignite-tc-helper-web/src/main/webapp/statistics.html ########## @@ -0,0 +1,213 @@ +<html> +<head> + <title>Ignite Teamcity - statistics master's branch</title> + <link rel="icon" href="img/leaf-icon-png-7066.png"> + <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> + <link rel="stylesheet" href="css/style-1.5.css"> + + <script src="https://code.jquery.com/jquery-1.12.4.js"></script> + <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> + <script src="js/common-1.6.js"></script> + <script src="js/testfails-2.0.js"></script> + <style> + table { + width: 70%; + border-collapse: collapse; + } + td, th { + + padding: 10px 5px 10px 5px; + } + th { + text-align: left; + padding: 5px; + background-color: #f5f5ff; + color: #000000; + } + tr:nth-child(odd) { background-color: #fafaff; } + </style> +</head> +<body> +<script> + var g_shownDataHashCodeHex = "" + var g_updTimer = null; + + $(document).ready(function() { + $.getScript("js/testfails-2.0.js", function(data, textStatus, jqxhr){ }); + + $( document ).tooltip(); + loadData(); + //todo fix setInterval( function() { checkForUpdate(); }, 30000); + + $.ajax({ url: "rest/branches/version", success: showVersionInfo, error: showErrInLoadStatus }); + + if(g_updTimer==null) { + g_updTimer=setTimeout(tstTimeout, 3200); + } + setInterval(tstTimeout, 10000); + }); + + function tstTimeout() { + + if(g_updTimer!=null) { + clearTimeout(g_updTimer); + g_updTimer=null; + } + + + var d = new Date(); + var n = d.getTime(); + + // $(document.body).prepend("timeout at "+n+"<br>"); + + + if(g_updTimer==null) { + g_updTimer=setTimeout(tstTimeout, 3200); + } + } + + function parmsForRest() { + var curReqParms = ""; + var server = findGetParameter("server"); + if(server!=null) { + curReqParms += "&server=" + server; + } + + var buildType = findGetParameter("buildType"); + if(buildType!=null) { + curReqParms += "&buildType=" + buildType; + } + + var branch = findGetParameter("branch"); + if(branch!=null) { + curReqParms += "&branch=" + branch; + } + + var count = findGetParameter("count"); + if(count!=null) { + curReqParms += "&count=" + count; + } + + var sinceDate = findGetParameter("sinceDate"); + if(sinceDate!=null) { + curReqParms += "&sinceDate=" + sinceDate; + } + + var untilDate = findGetParameter("untilDate"); + if(untilDate!=null) { + curReqParms += "&untilDate=" + untilDate; + } + + curReqParms = curReqParms.replace("&","?"); + + return curReqParms; + } + + function loadData() { + var curFailuresUrl = "rest/build/history" + parmsForRest(); + + $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Please wait"); + $.ajax({ + url: curFailuresUrl, + success: function(result) { + if(result.updateRequired || (isDefinedAndFilled(result.runningUpdates) && result.runningUpdates>0)) { + setTimeout(checkForUpdate, 3000) + $("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Updating"); + } else { + $("#loadStatus").html(""); + } + showData(result); + g_shownDataHashCodeHex = isDefinedAndFilled(result.hashCodeHex) ? result.hashCodeHex : ""; + }, + error: showErrInLoadStatus + }); + } + function showData(result) { + $("#statistics").html(showBuildHistory(result)); + } + + function median(arr){ + arr = arr.sort(function(a, b){ return a - b; }); + var i = arr.length / 2; + return i % 1 == 0 ? (arr[i - 1] + arr[i]) / 2 : arr[Math.floor(i)]; + } + + function formatString(string) { + if (string.indexOf("_") < string.indexOf(":")) + string = string.substring(string.indexOf("_") + 1); + + return "<b>" + string.substring(0, string.indexOf(":") + 1) + "</b>" + string.substring(string.indexOf(":") + 1); + } + + function showBuildHistory(result) { + var res = "<table><tr><th>#</th><th>Id</th><th>Total tests</th><th>Failed tests</th><th>Ignored tests</th>" + + "<th>Muted tests</th><th>Total issues</th><th>Total run time</th></tr>"; + + var problemCountMin = result[0].problemsCount; + var problemCountMax = problemCountMin; + var problemCounts = []; + var average = 0; + + for (var i = 0; i < result.length; i++) { + var buildStatistics = result[i]; + + problemCounts[i] = buildStatistics.problemsCount; + + if (problemCounts[i] > problemCountMax) problemCountMax = problemCounts[i]; + + if (problemCounts[i] < problemCountMin) problemCountMin = problemCounts[i]; + + average += problemCounts[i] / buildStatistics.build.testOccurrences.failed; + + res += "<tr><td>" + (i + 1) + "</td>" + + "<td><a href='" + buildStatistics.build.webUrl + "'>" + buildStatistics.build.id + "</a></td>" + + "<td>" + buildStatistics.build.testOccurrences.count + "</td>" + + "<td>" + buildStatistics.build.testOccurrences.failed + "</td>" + + "<td>" + buildStatistics.build.testOccurrences.ignored + "</td>" + + "<td>" + buildStatistics.build.testOccurrences.muted + "</td><td>"; + + if (buildStatistics.fullRes.length > 0) { + res += "<details><summary>" + formatString(buildStatistics.shortRes) + "</summary><p>"; + + for (var k = 0; k < buildStatistics.fullRes.length; k++) { + res += (k + 1) + ". " + formatString(buildStatistics.fullRes[k]) + "<br>"; + } + + res += "</p></details><br>"; + } else { + res += "<p>" + buildStatistics.shortRes + "</p>"; + } + + var issuesArr = buildStatistics.relatedIssues; + + if (issuesArr.length > 0) { + res += "<details><summary>Related issues [" + issuesArr.length + "]</summary><p>"; + + for (var j = 0; j < issuesArr.length; j++) { + var issue = issuesArr[j]; + + if (j !== 0) res += ", "; + + res += "<a href='" + issue.url + "'>" + issue.id + "</a>"; + } + + res += "</p></details>"; + } + + res += "</td><td>" + buildStatistics.durationPrintable + "</td></tr>"; + } + + res += "</table><br>min: " + problemCountMin + "; max: " + problemCountMax + + "; median: " + (Math.round(median(problemCounts) * 1000) / 1000) + + "; average: " + (Math.round(average / result.length * 1000) / 1000) + "<br><br>"; + + return res; + Review comment: Redundant blank line. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services