Added filter support into base KPI report
Change-Id: I36a45a3162f3f84cd3f0390a037ddb25ecbd0b15
This commit is contained in:
@@ -39,19 +39,28 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<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({
|
$.ajax({
|
||||||
url: make_uri(url, query_options),
|
url: make_uri(url, query_options),
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
data = data["stats"];
|
data = data["stats"];
|
||||||
|
var position = -1;
|
||||||
var index = -1;
|
var index = -1;
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (data_filter) {
|
||||||
|
if (!data_filter(data[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
sum += data[i].metric;
|
sum += data[i].metric;
|
||||||
|
if (data[i].index) {
|
||||||
|
index ++;
|
||||||
|
}
|
||||||
if (data[i].id == item_id) {
|
if (data[i].id == item_id) {
|
||||||
index = i;
|
position = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +69,11 @@
|
|||||||
goal: goal
|
goal: goal
|
||||||
};
|
};
|
||||||
|
|
||||||
if (index < 0) {
|
if (position < 0) {
|
||||||
result.info = "Item " + item_id + " is not found in the stats";
|
result.info = "Item " + item_id + " is not found in the stats";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var comparison_result = comparator(data[index], sum);
|
var comparison_result = comparator(data[position], sum);
|
||||||
result.mark = comparison_result.mark;
|
result.mark = comparison_result.mark;
|
||||||
result.info = comparison_result.info;
|
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 () {
|
$(document).ready(function () {
|
||||||
process_stats(container_id, "/api/1.0/stats/" + item_type, query_options, item_id, goal,
|
process_stats(container_id, "/api/1.0/stats/" + item_type, query_options, item_id, goal,
|
||||||
function(item, sum) {
|
function(item, sum) {
|
||||||
@@ -84,7 +93,7 @@
|
|||||||
"Position " + item.index + " is worse than the goal position " + position,
|
"Position " + item.index + " is worse than the goal position " + position,
|
||||||
value: item.index
|
value: item.index
|
||||||
}
|
}
|
||||||
});
|
}, data_filter);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
goal_position_in_top("kpi_container_position", {release: "icehouse", metric: "marks", project_type: "openstack"},
|
goal_position_in_top("kpi_container_position", {release: "icehouse", metric: "marks", project_type: "openstack"},
|
||||||
"engineers", "boris-42", 5, "Be in top 5 by reviews");
|
"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"},
|
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",
|
goal_percentage_in_top_less_than("kpi_container_percentage",
|
||||||
{release: "all", metric: "commits", project_type: "stackforge", module: "stackalytics"},
|
{release: "all", metric: "commits", project_type: "stackforge", module: "stackalytics"},
|
||||||
|
Reference in New Issue
Block a user