Don't display analytics if not enough data
This commit is contained in:
@@ -34,6 +34,10 @@ class ProjectAnalytic extends Base
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($total === 0) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($metrics as &$metric) {
|
foreach ($metrics as &$metric) {
|
||||||
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
|
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
|
||||||
}
|
}
|
||||||
@@ -71,6 +75,10 @@ class ProjectAnalytic extends Base
|
|||||||
$metrics[$user]['nb_tasks']++;
|
$metrics[$user]['nb_tasks']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($total === 0) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($metrics as &$metric) {
|
foreach ($metrics as &$metric) {
|
||||||
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
|
$metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('Task distribution') ?></h2>
|
<h2><?= t('Task distribution') ?></h2>
|
||||||
</div>
|
</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>
|
<div id="chart" data-url="<?= Helper\u('analytic', 'tasks', array('project_id' => $project['id'])) ?>"></div>
|
||||||
<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>
|
<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 ?>
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('User repartition') ?></h2>
|
<h2><?= t('User repartition') ?></h2>
|
||||||
</div>
|
</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>
|
<div id="chart" data-url="<?= Helper\u('analytic', 'users', array('project_id' => $project['id'])) ?>"></div>
|
||||||
<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>
|
<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 ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user