Improve class ProjectDailyColumnStats

This commit is contained in:
Frederic Guillot
2016-01-16 19:19:05 -05:00
parent 73ff5ec89b
commit 2e4c2b6e05
6 changed files with 420 additions and 226 deletions

View File

@@ -35,15 +35,7 @@ class Analytic extends Base
public function leadAndCycleTime()
{
$project = $this->getProject();
$values = $this->request->getValues();
$from = $this->request->getStringParam('from', date('Y-m-d', strtotime('-1week')));
$to = $this->request->getStringParam('to', date('Y-m-d'));
if (! empty($values)) {
$from = $values['from'];
$to = $values['to'];
}
list($from, $to) = $this->getDates();
$this->response->html($this->layout('analytic/lead_cycle_time', array(
'values' => array(
@@ -59,6 +51,32 @@ class Analytic extends Base
)));
}
/**
* Show comparison between actual and estimated hours chart
*
* @access public
*/
public function compareHours()
{
$project = $this->getProject();
$params = $this->getProjectFilters('analytic', 'compareHours');
$query = $this->taskFilter->create()->filterByProject($params['project']['id'])->getQuery();
$paginator = $this->paginator
->setUrl('analytic', 'compareHours', array('project_id' => $project['id']))
->setMax(30)
->setOrder(TaskModel::TABLE.'.id')
->setQuery($query)
->calculate();
$this->response->html($this->layout('analytic/compare_hours', array(
'project' => $project,
'paginator' => $paginator,
'metrics' => $this->estimatedTimeComparisonAnalytic->build($project['id']),
'title' => t('Compare hours for "%s"', $project['name']),
)));
}
/**
* Show average time spent by column
*
@@ -138,17 +156,7 @@ class Analytic extends Base
private function commonAggregateMetrics($template, $column, $title)
{
$project = $this->getProject();
$values = $this->request->getValues();
$this->projectDailyColumnStats->updateTotals($project['id'], date('Y-m-d'));
$from = $this->request->getStringParam('from', date('Y-m-d', strtotime('-1week')));
$to = $this->request->getStringParam('to', date('Y-m-d'));
if (! empty($values)) {
$from = $values['from'];
$to = $values['to'];
}
list($from, $to) = $this->getDates();
$display_graph = $this->projectDailyColumnStats->countDays($project['id'], $from, $to) >= 2;
@@ -166,29 +174,18 @@ class Analytic extends Base
)));
}
/**
* Show comparison between actual and estimated hours chart
*
* @access public
*/
public function compareHours()
private function getDates()
{
$project = $this->getProject();
$params = $this->getProjectFilters('analytic', 'compareHours');
$query = $this->taskFilter->create()->filterByProject($params['project']['id'])->getQuery();
$values = $this->request->getValues();
$paginator = $this->paginator
->setUrl('analytic', 'compareHours', array('project_id' => $project['id']))
->setMax(30)
->setOrder(TaskModel::TABLE.'.id')
->setQuery($query)
->calculate();
$from = $this->request->getStringParam('from', date('Y-m-d', strtotime('-1week')));
$to = $this->request->getStringParam('to', date('Y-m-d'));
$this->response->html($this->layout('analytic/compare_hours', array(
'project' => $project,
'paginator' => $paginator,
'metrics' => $this->estimatedTimeComparisonAnalytic->build($project['id']),
'title' => t('Compare hours for "%s"', $project['name']),
)));
if (! empty($values)) {
$from = $values['from'];
$to = $values['to'];
}
return array($from, $to);
}
}