Add new analytic component "Estimated vs actual time per column"
This commit is contained in:
committed by
GitHub
parent
6cadf82a63
commit
a267aa368b
49
app/Analytic/EstimatedActualColumnAnalytic.php
Normal file
49
app/Analytic/EstimatedActualColumnAnalytic.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Analytic;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Estimated vs actual time per column
|
||||
*
|
||||
* @package analytic
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class EstimatedActualColumnAnalytic extends Base
|
||||
{
|
||||
/**
|
||||
* Build report
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @return array
|
||||
*/
|
||||
public function build($project_id)
|
||||
{
|
||||
$rows = $this->db->table(TaskModel::TABLE)
|
||||
->columns('SUM(time_estimated) AS hours_estimated', 'SUM(time_spent) AS hours_spent', 'column_id')
|
||||
->eq('project_id', $project_id)
|
||||
->groupBy('column_id')
|
||||
->findAll();
|
||||
|
||||
$columns = $this->columnModel->getList($project_id);
|
||||
|
||||
$metrics = [];
|
||||
foreach ($columns as $column_id => $column_title) {
|
||||
$metrics[$column_id] = array(
|
||||
'hours_spent' => 0,
|
||||
'hours_estimated' => 0,
|
||||
'title' => $column_title,
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$metrics[$row['column_id']]['hours_spent'] = (float) $row['hours_spent'];
|
||||
$metrics[$row['column_id']]['hours_estimated'] = (float) $row['hours_estimated'];
|
||||
}
|
||||
|
||||
return $metrics;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user