Added filter support into base KPI report

Change-Id: I36a45a3162f3f84cd3f0390a037ddb25ecbd0b15
This commit is contained in:
Ilya Shakhat 2013-12-26 19:41:33 +04:00
parent fab294a7de
commit 9dc21b6840
2 changed files with 16 additions and 7 deletions

View File

@ -39,19 +39,28 @@
<script type="text/javascript">
function process_stats(container_id, url, query_options, item_id, goal, comparator) {
function process_stats(container_id, url, query_options, item_id, goal, comparator, data_filter) {
$.ajax({
url: make_uri(url, query_options),
dataType: "jsonp",
success: function (data) {
data = data["stats"];
var position = -1;
var index = -1;
var sum = 0;
for (var i = 0; i < data.length; i++) {
if (data_filter) {
if (!data_filter(data[i])) {
continue;
}
}
sum += data[i].metric;
if (data[i].index) {
index ++;
}
if (data[i].id == item_id) {
index = i;
position = index;
}
}
@ -60,11 +69,11 @@
goal: goal
};
if (index < 0) {
if (position < 0) {
result.info = "Item " + item_id + " is not found in the stats";
}
else {
var comparison_result = comparator(data[index], sum);
var comparison_result = comparator(data[position], sum);
result.mark = comparison_result.mark;
result.info = comparison_result.info;
}
@ -73,7 +82,7 @@
});
}
function goal_position_in_top(container_id, query_options, item_type, item_id, position, goal) {
function goal_position_in_top(container_id, query_options, item_type, item_id, position, goal, data_filter) {
$(document).ready(function () {
process_stats(container_id, "/api/1.0/stats/" + item_type, query_options, item_id, goal,
function(item, sum) {
@ -84,7 +93,7 @@
"Position " + item.index + " is worse than the goal position " + position,
value: item.index
}
});
}, data_filter);
});
}

View File

@ -13,7 +13,7 @@
goal_position_in_top("kpi_container_position", {release: "icehouse", metric: "marks", project_type: "openstack"},
"engineers", "boris-42", 5, "Be in top 5 by reviews");
goal_position_in_top("kpi_container_position", {release: "icehouse", metric: "marks", project_type: "openstack", module: "glance", exclude: "core"},
"engineers", "boris-42", 3, "Be in top 3 among non-core reviewers");
"engineers", "boris-42", 5, "Be in top 5 among non-core reviewers", function(data_line) { return !data_line.core });
goal_percentage_in_top_less_than("kpi_container_percentage",
{release: "all", metric: "commits", project_type: "stackforge", module: "stackalytics"},