From 3fd72e42cf7c6b49e23097400e64f883d37f57e4 Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Fri, 6 Dec 2013 20:54:05 +0400 Subject: [PATCH] Added KPI goal specified as absolute metric value + renamed example template to 'example.html' + added example on new KPI goal Change-Id: I531dfe106bb19db868424db6a03dcb7cad7d9a30 --- dashboard/kpi.py | 4 ++-- dashboard/templates/kpi/base_kpi.html | 21 ++++++++++++++++--- .../templates/kpi/{kpi.html => example.html} | 2 ++ 3 files changed, 22 insertions(+), 5 deletions(-) rename dashboard/templates/kpi/{kpi.html => example.html} (85%) diff --git a/dashboard/kpi.py b/dashboard/kpi.py index b66ae3474..ef793c743 100644 --- a/dashboard/kpi.py +++ b/dashboard/kpi.py @@ -21,8 +21,8 @@ from dashboard import decorators blueprint = flask.Blueprint('kpi', __name__, url_prefix='/kpi') -@blueprint.route('/group') +@blueprint.route('/example') @decorators.templated() @decorators.exception_handler() -def kpi(): +def example(): return diff --git a/dashboard/templates/kpi/base_kpi.html b/dashboard/templates/kpi/base_kpi.html index 97b234b92..dc97a623e 100644 --- a/dashboard/templates/kpi/base_kpi.html +++ b/dashboard/templates/kpi/base_kpi.html @@ -80,8 +80,23 @@ var mark = item.index <= position; return { mark: mark, - info: mark? "Achieved position is " + position: - "Position " + item.index + " is worse than target position " + position, + info: mark? "Achieved position is " + item.index: + "Position " + item.index + " is worse than the goal position " + position, + value: item.index + } + }); + }); + } + + function goal_metric(container_id, query_options, item_type, item_id, metric, goal) { + $(document).ready(function () { + process_stats(container_id, "/api/1.0/stats/" + item_type, query_options, item_id, goal, + function(item, sum) { + var mark = item.metric > metric; + return { + mark: mark, + info: mark? "Achieved metric " + item.metric: + "Position " + item.metric + " is worse than the goal in " + metric, value: item.index } }); @@ -98,7 +113,7 @@ var goal_percentage_formatted = Math.round(goal_percentage * 100) + "%"; return { mark: mark, - info: mark? "Achieved percentage " + goal_percentage_formatted: + info: mark? "Achieved percentage " + percentage_formatted: "Value " + percentage_formatted + " is more than the goal " + goal_percentage_formatted, value: percentage_formatted } diff --git a/dashboard/templates/kpi/kpi.html b/dashboard/templates/kpi/example.html similarity index 85% rename from dashboard/templates/kpi/kpi.html rename to dashboard/templates/kpi/example.html index 9a91e40a4..46dfcb043 100644 --- a/dashboard/templates/kpi/kpi.html +++ b/dashboard/templates/kpi/example.html @@ -19,6 +19,8 @@ {release: "all", metric: "commits", project_type: "stackforge", module: "stackalytics"}, "companies", "Mirantis", 0.8, "Mirantis contribution is less than 80%"); + goal_metric("kpi_container_position", {release: "icehouse", metric: "bpd", project_type: "openstack", module: "glance", exclude: "core"}, + "modules", "glance", 10, "File at least 10 blueprints into Glance"); }); {% endblock %}