Add regex filter to job page graphs

This commit add regex filters to the job page graphs. The graph's regex
filter was introduced in the home/group page. However, I forgot to care
about the job page at that time.

Change-Id: If4bcebda66d83a26b9ef16429e1fca17ffedd918
Closes-Bug: #1590059
This commit is contained in:
Masayuki Igawa 2016-06-17 14:45:03 +09:00
parent dcec891e5f
commit 6ebb2e932c
3 changed files with 38 additions and 5 deletions

View File

@ -29,7 +29,7 @@ function JobController(
vm.hold -= 1;
};
vm.processData = function(data) {
vm.processData = function(data, regex) {
vm.chartData = [];
vm.chartDataRate = [];
vm.tests = [];
@ -38,12 +38,19 @@ function JobController(
return;
}
var pattern = null;
try {
pattern = new RegExp(regex);
} catch (e) {
pattern = '';
}
// prepare chart data
var tests = {};
var passEntries = [];
var failEntries = [];
var skipEntries = [];
var failRateEntries = [];
var DEFAULT_FAIL_RATE = 0;
var date = '';
for (date in data.tests) {
@ -65,6 +72,9 @@ function JobController(
var testData = testsInDate[testName];
var cleanTestName = testService.removeIdNoise(testName);
if (!pattern.test(cleanTestName)) {
continue;
}
if (!tests[cleanTestName]) {
var testMetrics = {
@ -115,9 +125,10 @@ function JobController(
y: totalFail
});
failRate = totalFail / (totalFail + totalPass) || DEFAULT_FAIL_RATE;
failRateEntries.push({
x: new Date(date).getTime(),
y: totalFail / (totalFail + totalPass)
y: failRate
});
skipEntries.push({
@ -153,7 +164,7 @@ function JobController(
stop_date: viewService.periodEnd(),
datetime_resolution: viewService.resolution().key
}).then(function(response) {
vm.processData(response.data);
vm.processData(response.data, vm.searchTest);
vm.loaded = true;
});
healthService.getRecentGroupedRuns('build_name', vm.name).then(function(response) {
@ -179,6 +190,7 @@ function JobController(
vm.onSearchChange = function() {
$location.search('searchTest', $scope.job.searchTest).replace();
vm.loadData();
};
}

View File

@ -68,6 +68,7 @@ function HealthService($http, config) {
service.getTestsFromBuildName = function(buildName, options) {
return config.get().then(function(config) {
return $http.jsonp(config.apiRoot + '/build_name/' + buildName + '/test_runs', {
cache: true,
params: angular.extend(options, { callback: 'JSON_CALLBACK' })
});
});

View File

@ -17,8 +17,18 @@
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-heading panel-controls">
<h3 class="panel-title">Tests</h3>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text"
class="form-control"
placeholder="Search for test with regex"
ng-model="job.searchTest"
ng-model-options="{debounce: 250}"
ng-change="job.onSearchChange()"
uib-tooltip="You can see {{job.tests.length}} test(s). Details are at the bottom.">
</div>
</div>
<div class="panel-body">
<chart-line data="job.chartData" width="100%" height="250"
@ -26,8 +36,18 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-heading panel-controls">
<h3 class="panel-title">Tests Failure Rate</h3>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text"
class="form-control"
placeholder="Search for test with regex"
ng-model="job.searchTest"
ng-model-options="{debounce: 250}"
ng-change="job.onSearchChange()"
uib-tooltip="You can see {{job.tests.length}} test(s). Details are at the bottom.">
</div>
</div>
<div class="panel-body">
<chart-line data="job.chartDataRate" width="100%" height="250"