Skip to content

Commit

Permalink
Bug 1260791 - UI support for manually created performance alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
wlach committed May 31, 2016
1 parent bede7c1 commit 3f84b3f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
27 changes: 24 additions & 3 deletions ui/js/controllers/perf/graphs.js
Expand Up @@ -21,6 +21,25 @@ perf.controller('GraphsCtrl', [
$scope.showToolTipTimeout = null;
$scope.seriesList = [];

$scope.createAlert = function(dataPoint) {
$scope.creatingAlert = true;
PhAlerts.createAlert(dataPoint).then(function(alertSummaryId) {
PhAlerts.getAlertSummaries({
seriesSignature: dataPoint.series.seriesSignature,
repository: dataPoint.project.id
}).then(function(alertSummaryData) {
$scope.creatingAlert = false;

var alertSummary = _.find(alertSummaryData.results,
{ id: alertSummaryId });
$scope.tooltipContent.alertSummary = alertSummary;

dataPoint.series.relatedAlertSummaries = alertSummaryData.results;
plotGraph();
});
});
};

function getSeriesDataPoint(flotItem) {
// gets universal elements of a series given a flot item

Expand Down Expand Up @@ -107,9 +126,10 @@ perf.controller('GraphsCtrl', [
project: _.findWhere($rootScope.repos,
{ name: phSeries.projectName }),
revisionUrl: thServiceDomain + '#/jobs?repo=' + phSeries.projectName,
prevResultSetId: prevResultSetId,
resultSetId: dataPoint.resultSetId,
jobId: phSeries.flotSeries.jobIdData[index],
test: phSeries.name,
platform: phSeries.platform,
series: phSeries,
value: Math.round(v*1000)/1000,
deltaValue: dv.toFixed(1),
deltaPercentValue: (100 * dvp).toFixed(1),
Expand Down Expand Up @@ -207,7 +227,8 @@ perf.controller('GraphsCtrl', [
// if we have a highlighted revision(s), highlight all points that
// correspond to that
$scope.seriesList.forEach(function(series, i) {
if (series.visible && series.highlightedPoints.length) {
if (series.visible && series.highlightedPoints &&
series.highlightedPoints.length) {
_.forEach(series.highlightedPoints, function(highlightedPoint) {
$scope.plot.highlight(i, highlightedPoint);
});
Expand Down
16 changes: 15 additions & 1 deletion ui/js/models/perf/alerts.js
Expand Up @@ -208,7 +208,21 @@ treeherder.factory('PhAlerts', [
});
});
},
changeAlertSummaryStatus: function(alertSummaryId, open) {
createAlert: function(data) {
return $http.post(thServiceDomain + '/api/performance/alertsummary/', {
repository_id: data.project.id,
framework_id: data.series.frameworkId,
result_set_id: data.resultSetId,
prev_result_set_id: data.prevResultSetId
}).then(function(response) {
var newAlertSummaryId = response.data.alert_summary_id;
return $http.post(thServiceDomain + '/api/performance/alert/', {
summary_id: newAlertSummaryId,
signature_id: data.series.id
}).then(function() {
return newAlertSummaryId;
});
});
}
};
}]);
1 change: 1 addition & 0 deletions ui/js/perf.js
Expand Up @@ -43,6 +43,7 @@ treeherder.factory('PhSeries', ['$http', 'thServiceDomain', 'ThOptionCollectionM
var options = _getSeriesOptions(signatureProps, optionCollectionMap);

return {
id: signatureProps['id'],
name: _getSeriesName(signatureProps, optionCollectionMap),
testName: _getTestName(signatureProps), // unadorned with platform/option info
suite: signatureProps['suite'],
Expand Down
10 changes: 8 additions & 2 deletions ui/partials/perf/alertsctrl.html
Expand Up @@ -162,10 +162,16 @@
</div>
</td>
<td class="alert-confidence">
<span class="detail-hint"
<span ng-if="!alert.manually_created"
class="detail-hint"
uib-tooltip="Confidence value as calculated by Perfherder alerts. Note that this is NOT the same as the calculation used in the compare view"
tooltip-placement="left">
{{alert.t_value}}
<span>
{{alert.t_value}}
</span>
</span>
<span ng-if="alert.manually_created" uib-tooltip="Sheriff-created alert">
<span class="fa fa-user"/>
</span>
</td>
</tr>
Expand Down
15 changes: 12 additions & 3 deletions ui/partials/perf/graphsctrl.html
Expand Up @@ -56,9 +56,9 @@
<div>
<button id="close-popup" type="button" class="close graphchooser-close"
ng-click="closePopup()"><span aria-hidden="true">&times;</span></button>
<p id="tt-series"><span ng-bind="tooltipContent.test"/>
<p id="tt-series"><span ng-bind="tooltipContent.series.test"/>
(<span ng-bind="tooltipContent.project.name"/>)</p>
<p id="tt-series2" class="small"><span ng-bind="tooltipContent.platform"/></p>
<p id="tt-series2" class="small"><span ng-bind="tooltipContent.series.platform"/></p>
</div>
<div>
<p id="tt-v" ng-bind="tooltipContent.value"></p>
Expand All @@ -75,11 +75,20 @@
<a ng-href="#/comparesubtest?originalProject={{tooltipContent.project.name}}&newProject={{tooltipContent.project.name}}&originalRevision={{tooltipContent.prevRevision}}&newRevision={{tooltipContent.revision}}&originalSignature={{selectedDataPoint.signature}}&newSignature={{selectedDataPoint.signature}}&framework={{selectedDataPoint.frameworkId}}" target="_blank">compare</a>)
</span>
</p>
<p ng-show="tooltipContent.alertSummary">
<p ng-if="tooltipContent.alertSummary">
<i class="text-warning fa fa-exclamation-circle"></i>
<a href="perf.html#/alerts?id={{tooltipContent.alertSummary.id}}">
Alert #{{tooltipContent.alertSummary.id}}</a>
<span class="text-muted">({{tooltipContent.alertSummary.getStatusText()}})</span>
</p>
<p class="text-muted" ng-if="!tooltipContent.alertSummary">
<span ng-if="!creatingAlert">
No alert (<a href="" ng-click="createAlert(tooltipContent)">create</a>)
</span>
<span ng-if="creatingAlert">
Creating alert... <i class="fa fa-spinner fa-pulse"></i>
</span>
</p>
<p ng-hide="tooltipContent.revision">
<span ng-hide="tooltipContent.revisionInfoAvailable">Revision info unavailable</span>
<span ng-show="tooltipContent.revisionInfoAvailable">Loading revision...</span>
Expand Down

0 comments on commit 3f84b3f

Please sign in to comment.