Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Commit

Permalink
Manually add regressions + a graph
Browse files Browse the repository at this point in the history
  • Loading branch information
h4writer committed May 8, 2015
1 parent a1c31e8 commit 5e64431
Show file tree
Hide file tree
Showing 14 changed files with 613 additions and 22 deletions.
15 changes: 15 additions & 0 deletions website/internals.php
Expand Up @@ -11,6 +11,14 @@ function init_database()
mysql_select_db("dvander") or die("ERROR: " . mysql_error());
}

function username()
{
if (!isset($_SESSION['persona']))
return "guest";
else
return $_SESSION['persona'];
}

function has_permissions()
{
if (!isset($_SESSION['persona']))
Expand All @@ -25,6 +33,13 @@ function has_permissions()
return false;
}

function GET_bool($name)
{
if (isset($_GET[$name]))
return $_GET[$name] === "true" || $_GET[$name] === '1';
return false;
}

function GET_int($name)
{
if (isset($_GET[$name]))
Expand Down
24 changes: 24 additions & 0 deletions website/regressions/css/main.css
Expand Up @@ -382,3 +382,27 @@ html, body {
.box .regression .score {
text-align: center;
height: 1.5em; }

.details table {
width: 900px;
border: 1px SOLID #dddddd;
background-color: #f2f2f2;
color: #222222;
padding: 6px;
margin-right: 2%;
margin-bottom: 30px; }
.details table td {
background-color: white;
padding: 6px; }
.details table th {
text-align: left; }
.details table .status td {
text-transform: uppercase; }
.details table .edit {
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
margin-left: 6px;
margin-right: 6px;
float: right;
cursor: pointer; }
41 changes: 41 additions & 0 deletions website/regressions/data-graph.php
@@ -0,0 +1,41 @@
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

require_once("../internals.php");
require_once("data-func.php");
init_database();

$amount = Array();

$query = mysql_query("SELECT build_id FROM awfy_regression
INNER JOIN awfy_build ON awfy_build.id = build_id
WHERE (mode_id = 14 OR mode_id = 26 or mode_id = 32 or mode_id = 20) AND
status != 'fixed' AND status != 'improvement'");
while ($regs = mysql_fetch_object($query)) {
$qScore = mysql_query("SELECT count(*) as count FROM awfy_regression_score
WHERE build_id = ".$regs->build_id);
$score = mysql_fetch_object($qScore);
$qBreakdown = mysql_query("SELECT count(*) as count FROM awfy_regression_breakdown
WHERE build_id = ".$regs->build_id);
$breakdown = mysql_fetch_object($qBreakdown);
$qDate = mysql_query("SELECT stamp FROM awfy_build
LEFT JOIN awfy_run ON awfy_run.id = awfy_build.run_id
WHERE awfy_build.id = ".$regs->build_id);
$date = mysql_fetch_object($qDate);
$date_str = date("Y", $date->stamp).",".(date("m", $date->stamp)*1-1).",".date("d", $date->stamp);

$amount[$date_str] += $score->count + $breakdown->count;
}

echo "[";
$first = true;
foreach ($amount as $key => $value) {
if (!$first)
echo ',';
echo '{"c":[{"v":"Date('.$key.')"},{"v":'.$value.'}]}';
$first = false;
}
echo "]";
?>
48 changes: 48 additions & 0 deletions website/regressions/data-score.php
@@ -0,0 +1,48 @@
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

require_once("../internals.php");
require_once("data-func.php");
init_database();

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

$request->id = (int) $request->id;
if (!isset($request->subtest))
$request->subtest = false;

if ($request->subtest == 1 || $request->subtest == 'true') {
$query = mysql_query("SELECT mode_id, machine, stamp, score, suite_test_id
FROM `awfy_breakdown`
LEFT JOIN awfy_build ON awfy_build.id = build_id
LEFT JOIN awfy_run ON awfy_run.id = run_id
WHERE awfy_breakdown.id = ".$request->id) or die(mysql_error());
$data = mysql_fetch_assoc($query);

$prev = prev_suite_test($data["stamp"], $data["machine"],
$data["mode_id"], $data["suite_test_id"]);
if (count($prev) == 1)
$data["prev_score"] = $prev[0]["score"];

$data["suite_version_id"] = get("suite_test", $data["suite_test_id"], "suite_version_id");
$data["suite_test"] = get("suite_test", $data["suite_test_id"], "name");

die(json_encode($data));
} else {
$query = mysql_query("SELECT mode_id, machine, stamp, score, suite_version_id
FROM `awfy_score`
LEFT JOIN awfy_build ON awfy_build.id = build_id
LEFT JOIN awfy_run ON awfy_run.id = run_id
WHERE awfy_score.id = ".$request->id) or die(mysql_error());
$data = mysql_fetch_assoc($query);

$prev = prev_($data["stamp"], $data["machine"],
$data["mode_id"], $data["suite_version_id"]);
if (count($prev) == 1)
$data["prev_score"] = $prev[0]["score"];

die(json_encode($data));
}
56 changes: 56 additions & 0 deletions website/regressions/data-submit.php
@@ -0,0 +1,56 @@
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

require_once("../internals.php");
require_once("data-func.php");
init_database();

$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

$request->id = (int) $request->id;
if (!isset($request->subtest))
$request->subtest = false;

if ($request->subtest == 1 || $request->subtest == 'true') {
$build_id = get("breakdown", $request->id, "build_id");
$suite_test_id = get("breakdown", $request->id, "suite_test_id");
$suite = get("suite_test", $suite_test_id, "name");

$query = mysql_query("SELECT id FROM awfy_regression_breakdown
WHERE breakdown_id = ".$request->id);
if (mysql_num_rows($query) == 0) {
mysql_query("INSERT INTO awfy_regression_breakdown
(build_id, breakdown_id) VALUES (".$build_id.",".$request->id.")");
}
} else {
$build_id = get("score", $request->id, "build_id");
$suite_version_id = get("score", $request->id, "suite_version_id");
$suite = get("suite_version", $suite_version_id, "name");

$query = mysql_query("SELECT id FROM awfy_regression_score
WHERE score_id = ".$request->id);
if (mysql_num_rows($query) == 0) {
mysql_query("INSERT INTO awfy_regression_score
(build_id, score_id) VALUES (".$build_id.",".$request->id.")");
}
}

$query = mysql_query("SELECT id FROM awfy_regression
WHERE build_id = ".$build_id);
if (mysql_num_rows($query) == 0) {
mysql_query("INSERT INTO awfy_regression
(build_id, status) VALUES (".$build_id.",'unconfirmed')");
$regression_id = mysql_insert_id();
} else {
$data = mysql_fetch_assoc($query);
$regression_id = $data["id"];
}

mysql_query("INSERT INTO awfy_regression_status
(regression_id, name, extra, stamp) VALUES
(".$regression_id.",'".username()."','Reported ".$suite." regression', UNIX_TIMESTAMP())");

echo $regression_id;
1 change: 1 addition & 0 deletions website/regressions/index.html
Expand Up @@ -16,6 +16,7 @@
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-route.js"></script>
<script src="https://login.persona.org/include.js"></script>
<script src="js/persona.js"></script>
<script type="text/javascript" src="js/ng-google-chart.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>

Expand Down
11 changes: 10 additions & 1 deletion website/regressions/js/app.js
@@ -1,6 +1,7 @@
var awfyApp = angular.module('awfyApp', [
'ngRoute',
'awfyControllers'
'awfyControllers',
'googlechart'
]);

awfyApp.config(['$routeProvider',
Expand All @@ -10,6 +11,14 @@ awfyApp.config(['$routeProvider',
templateUrl: 'partials/regression.html',
controller: 'regressionCtrl'
}).
when('/add/:subtest?/:id', {
templateUrl: 'partials/add.html',
controller: 'addCtrl'
}).
when('/graph', {
templateUrl: 'partials/graph.html',
controller: 'graphCtrl'
}).
when('/:search', {
templateUrl: 'partials/overview.html',
controller: 'overviewCtrl'
Expand Down
75 changes: 71 additions & 4 deletions website/regressions/js/controllers.js
Expand Up @@ -20,6 +20,25 @@ awfyCtrl.filter('linkify', function($sce, $parse) {
};
})

awfyCtrl.controller('addCtrl', ['$scope', '$http', '$routeParams', 'RegressionService', '$location',
function ($scope, $http, $routeParams, regression, $location) {
var data = {};
data["id"] = $routeParams.id * 1;
if ($routeParams.subtest)
data["subtest"] = 1;

$http.post('data-score.php', data).then(function(data) {
$scope.regression = regression.normalize_score(data.data);
});

$scope.submit = function() {
$http.post('data-submit.php', data).then(function(data) {
$location.path("/regression/"+(data.data*1));
});
};
}
]);

awfyCtrl.controller('regressionCtrl', ['$scope', '$http', '$routeParams', '$q', 'modalDialog',
'RegressionService', '$sce',
function ($scope, $http, $routeParams, $q, modalDialog, regression, $sce) {
Expand Down Expand Up @@ -95,7 +114,7 @@ awfyCtrl.controller('regressionCtrl', ['$scope', '$http', '$routeParams', '$q',
];

$q.all(requests).then(function(data) {
modalDialog.open("partials/graph.html", {
modalDialog.open("partials/graph-popup.html", {
"url": "http://arewefastyet.com/#"+
"machine="+regression.machine_id+"&"+
"view=single&"+
Expand Down Expand Up @@ -212,14 +231,37 @@ awfyCtrl.controller('regressionCtrl', ['$scope', '$http', '$routeParams', '$q',

awfyCtrl.service('RegressionService', ["MasterService",
function (master) {
this.normalize_score = function(score) {
score["machine_id"] = score["machine"]
score["machine"] = master["machines"][score["machine"]]["description"]
if (score["mode"])
score["mode_id"] = score["mode"]
score["mode"] = master["modes"][score["mode_id"]]["name"]
score["stamp"] = score["stamp"] * 1000

var suite_version = score["suite_version_id"]
var percent = ((score["score"] / score["prev_score"]) - 1) * 100
percent = Math.round(percent * 100)/100;
var suite = master["suiteversions"][suite_version]["suite"];
var direction = master["suites"][suite]["direction"];
var regressed = (direction == 1) ^ (percent > 0)

score["suite"] = master["suiteversions"][suite_version]["suite"]
score["suiteversion"] = master["suiteversions"][suite_version]["name"]
score["suitetest"] = score["suite_test"]
score["percent"] = percent
score["regression"] = regressed
return score;
}
this.normalize = function(regression) {
regression["machine_id"] = regression["machine"]
regression["machine"] = master["machines"][regression["machine"]]["description"]
regression["mode_id"] = regression["mode"]
regression["mode"] = master["modes"][regression["mode"]]["name"]
if (regression["mode"])
regression["mode_id"] = regression["mode"]
regression["mode"] = master["modes"][regression["mode_id"]]["name"]
regression["stamp"] = regression["stamp"] * 1000

if (regression["scores"].length > 0) {
if (regression["scores"] && regression["scores"].length > 0) {
var prev_cset = regression["scores"][0]["prev_cset"];
for (var j = 0; j < regression["scores"].length; j++) {
var score = regression["scores"][j]
Expand Down Expand Up @@ -413,3 +455,28 @@ awfyCtrl.controller('ffIconCtrl', function ($scope) {
}
});
});

awfyCtrl.controller('graphCtrl', ['$scope', '$http',
function ($scope, $http) {
$http.get('data-graph.php').then(function(data) {

$scope.chart = {
"type": "Calendar",
"cssStyle": "height:350px; width:1200px;",
"data": {
"cols": [
{ type: 'date', id: 'Date' },
{ type: 'number', id: 'Won/Loss' }
],
"rows": data.data
},
"options": {
title: "Reported noisy benchmark",
height: 350,
}

}

});
}
]);

0 comments on commit 5e64431

Please sign in to comment.