summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-16 19:19:05 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-16 19:19:05 -0500
commit2e4c2b6e0571690e8b8d0488dbb53e3373a86ff5 (patch)
treece725462022d39d8b8088cfdab4dd7e05b396d36 /app/Controller
parent73ff5ec89b711791b3993f9158dc9554a623602c (diff)
Improve class ProjectDailyColumnStats
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Analytic.php79
1 files changed, 38 insertions, 41 deletions
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php
index 26386029..d203fb8e 100644
--- a/app/Controller/Analytic.php
+++ b/app/Controller/Analytic.php
@@ -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(
@@ -60,6 +52,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
*
* @access public
@@ -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);
}
}