From 530f89ab8fef80f722c535b274bcfeaab7d82e22 Mon Sep 17 00:00:00 2001 From: Diego Pino Date: Wed, 2 May 2012 16:11:56 +0200 Subject: [PATCH] Fix bug, upper limit and lower limit in TaskCompletationLag should be +3,-2 when there's only one task FEA: ItEr76S15OrganizingPerProjectDashboard --- .../web/dashboard/DashboardModel.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java index 9eb9c17af..aac7b1d71 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java @@ -339,18 +339,36 @@ public class DashboardModel implements IDashboardModel { return histogram; } + /** + * Calculates the task completation deviations for the current order + * + * All the deviations are groups in Interval.MAX_INTERVALS intervals of + * equal size. If the order contains just one single task then, the upper + * limit will be the deviation of the task + 3, and the lower limit will be + * deviation of the task - 2 + * + * Each {@link Interval} contains the number of tasks that fit in that + * interval + * + * @return + */ @Override public Map calculateTaskCompletation() { Map result = new LinkedHashMap(); - final Integer one = Integer.valueOf(1); + Double max, min; // Get deviations of finished tasks, calculate max, min and delta List deviations = getTaskLagDeviations(); if (deviations.isEmpty()) { return result; } - Double max = Collections.max(deviations); - Double min = Collections.min(deviations); + if (deviations.size() == 1) { + max = deviations.get(0).doubleValue() + 3; + min = deviations.get(0).doubleValue() - 2; + } else { + max = Collections.max(deviations); + min = Collections.min(deviations); + } double delta = (max - min) / Interval.MAX_INTERVALS; // Create MAX_INTERVALS @@ -366,7 +384,7 @@ public class DashboardModel implements IDashboardModel { Interval interval = Interval.containingValue(intervals, each); if (interval != null) { Integer value = result.get(interval); - result.put(interval, value + one); + result.put(interval, value + 1); } } return result; @@ -395,6 +413,7 @@ public class DashboardModel implements IDashboardModel { * * @return */ + @Override public Map calculateEstimationAccuracy() { final Integer one = Integer.valueOf(1); Map result = new LinkedHashMap();