From f2122a8cd8500bb775b04971b48c6faaa1af2e0a Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Tue, 4 Sep 2012 15:51:34 +0000 Subject: adjust charts --- lib.php | 57 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'lib.php') diff --git a/lib.php b/lib.php index 5d1cfde..b6d6750 100644 --- a/lib.php +++ b/lib.php @@ -294,23 +294,39 @@ S; public static function js_draw_buildtime_chart($data, $id) { - $d = print_r($data, true); - $rows = array("['Duration', 'Builds']", '[1, 3]'); + // first pass + $newdata = array(); foreach ($data as $duration => $count) { + if (false !== strpos($duration, 'hour')) { + $newdata['> 1 hour'] += $count; + } else { + $d = explode(' ', $duration); + if ($d[0] > 15) { + $newdata['> 15 minutes'] += $count; + } else { + $newdata[$duration] = $count; + } + } + } + + $rows = array("['Duration', 'Builds']"); + foreach ($newdata as $duration => $count) { + if ($duration == '0 second') + $duration = '< 1 minute'; + $rows[] = sprintf("['%s', %d]", $duration, $count); } $rows = implode(', ', $rows); return << $count) { $rows[] = sprintf("['%s', %d]", $hour, $count); } $rows = implode(', ', $rows); return <<