Don't display analytics if not enough data

This commit is contained in:
Frédéric Guillot
2014-11-15 21:55:42 -05:00
parent aa6fffb05a
commit 557bc2c3cd
3 changed files with 64 additions and 46 deletions

View File

@@ -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);
}

View File

@@ -1,6 +1,10 @@
<div class="page-header">
<h2><?= t('Task distribution') ?></h2>
</div>
<?php if (empty($metrics)): ?>
<p class="alert"><?= t('Not enough data.') ?></p>
<?php else: ?>
<section id="analytic-task-repartition">
<div id="chart" data-url="<?= Helper\u('analytic', 'tasks', array('project_id' => $project['id'])) ?>"></div>
@@ -27,3 +31,4 @@
</table>
</section>
<?php endif ?>

View File

@@ -1,6 +1,10 @@
<div class="page-header">
<h2><?= t('User repartition') ?></h2>
</div>
<?php if (empty($metrics)): ?>
<p class="alert"><?= t('Not enough data.') ?></p>
<?php else: ?>
<section id="analytic-user-repartition">
<div id="chart" data-url="<?= Helper\u('analytic', 'users', array('project_id' => $project['id'])) ?>"></div>
@@ -27,3 +31,4 @@
</table>
</section>
<?php endif ?>