summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-15 21:55:42 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-15 21:55:42 -0500
commit557bc2c3cd1fd2dddf1d7c03731aaaf173cd2bb7 (patch)
tree717c5b015b52127dca2674bffcc98a3e92893e12 /app
parentaa6fffb05a7d84a36991341610675499b6ea8a79 (diff)
Don't display analytics if not enough data
Diffstat (limited to 'app')
-rw-r--r--app/Model/ProjectAnalytic.php8
-rw-r--r--app/Template/analytic/tasks.php51
-rw-r--r--app/Template/analytic/users.php51
3 files changed, 64 insertions, 46 deletions
diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php
index b62248eb..46f2242d 100644
--- a/app/Model/ProjectAnalytic.php
+++ b/app/Model/ProjectAnalytic.php
@@ -34,6 +34,10 @@ class ProjectAnalytic extends Base
);
}
+ if ($total === 0) {
+ return array();
+ }
+
foreach ($metrics as &$metric) {
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
}
@@ -71,6 +75,10 @@ class ProjectAnalytic extends Base
$metrics[$user]['nb_tasks']++;
}
+ if ($total === 0) {
+ return array();
+ }
+
foreach ($metrics as &$metric) {
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
}
diff --git a/app/Template/analytic/tasks.php b/app/Template/analytic/tasks.php
index 7ae9c254..01338d2e 100644
--- a/app/Template/analytic/tasks.php
+++ b/app/Template/analytic/tasks.php
@@ -1,29 +1,34 @@
<div class="page-header">
<h2><?= t('Task distribution') ?></h2>
</div>
-<section id="analytic-task-repartition">
-<div id="chart" data-url="<?= Helper\u('analytic', 'tasks', array('project_id' => $project['id'])) ?>"></div>
+<?php if (empty($metrics)): ?>
+ <p class="alert"><?= t('Not enough data.') ?></p>
+<?php else: ?>
+ <section id="analytic-task-repartition">
-<table>
- <tr>
- <th><?= t('Column') ?></th>
- <th><?= t('Number of tasks') ?></th>
- <th><?= t('Percentage') ?></th>
- </tr>
- <?php foreach ($metrics as $metric): ?>
- <tr>
- <td>
- <?= Helper\escape($metric['column_title']) ?>
- </td>
- <td>
- <?= $metric['nb_tasks'] ?>
- </td>
- <td>
- <?= n($metric['percentage']) ?>%
- </td>
- </tr>
- <?php endforeach ?>
-</table>
+ <div id="chart" data-url="<?= Helper\u('analytic', 'tasks', array('project_id' => $project['id'])) ?>"></div>
-</section>
+ <table>
+ <tr>
+ <th><?= t('Column') ?></th>
+ <th><?= t('Number of tasks') ?></th>
+ <th><?= t('Percentage') ?></th>
+ </tr>
+ <?php foreach ($metrics as $metric): ?>
+ <tr>
+ <td>
+ <?= Helper\escape($metric['column_title']) ?>
+ </td>
+ <td>
+ <?= $metric['nb_tasks'] ?>
+ </td>
+ <td>
+ <?= n($metric['percentage']) ?>%
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+ </section>
+<?php endif ?>
diff --git a/app/Template/analytic/users.php b/app/Template/analytic/users.php
index 89f00686..28e2fbbc 100644
--- a/app/Template/analytic/users.php
+++ b/app/Template/analytic/users.php
@@ -1,29 +1,34 @@
<div class="page-header">
<h2><?= t('User repartition') ?></h2>
</div>
-<section id="analytic-user-repartition">
-<div id="chart" data-url="<?= Helper\u('analytic', 'users', array('project_id' => $project['id'])) ?>"></div>
+<?php if (empty($metrics)): ?>
+ <p class="alert"><?= t('Not enough data.') ?></p>
+<?php else: ?>
+ <section id="analytic-user-repartition">
-<table>
- <tr>
- <th><?= t('User') ?></th>
- <th><?= t('Number of tasks') ?></th>
- <th><?= t('Percentage') ?></th>
- </tr>
- <?php foreach ($metrics as $metric): ?>
- <tr>
- <td>
- <?= Helper\escape($metric['user']) ?>
- </td>
- <td>
- <?= $metric['nb_tasks'] ?>
- </td>
- <td>
- <?= n($metric['percentage']) ?>%
- </td>
- </tr>
- <?php endforeach ?>
-</table>
+ <div id="chart" data-url="<?= Helper\u('analytic', 'users', array('project_id' => $project['id'])) ?>"></div>
-</section>
+ <table>
+ <tr>
+ <th><?= t('User') ?></th>
+ <th><?= t('Number of tasks') ?></th>
+ <th><?= t('Percentage') ?></th>
+ </tr>
+ <?php foreach ($metrics as $metric): ?>
+ <tr>
+ <td>
+ <?= Helper\escape($metric['user']) ?>
+ </td>
+ <td>
+ <?= $metric['nb_tasks'] ?>
+ </td>
+ <td>
+ <?= n($metric['percentage']) ?>%
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+ </section>
+<?php endif ?>