diff --git a/site/controllers/api.json.php b/site/controllers/api.json.php index 8a55546..774c01f 100644 --- a/site/controllers/api.json.php +++ b/site/controllers/api.json.php @@ -1251,6 +1251,13 @@ public function totals() //handle unexpected warnings from model set_error_handler(array($this, 'exception_error_handler')); $result = ImcFrontendHelper::getTotals(); + + // Calculate the difference between start and end date (in years, months & days). + $diff = date_diff(date_create($result[0]['newest_issue_date']), date_create($result[0]['oldest_issue_date'])); + $result[0]['years'] = $diff->y; + $result[0]['months'] = $diff->m; + $result[0]['days'] = $diff->d; + restore_error_handler(); $app->enqueueMessage('size: '.sizeof($result), 'info'); diff --git a/site/helpers/imc.php b/site/helpers/imc.php index 9eeedcc..67f2b6d 100644 --- a/site/helpers/imc.php +++ b/site/helpers/imc.php @@ -1025,6 +1025,8 @@ public static function getTotals($limit = null, $ts = null, $prior_to = null) (SELECT COUNT(*) FROM #__imc_votes WHERE state=1) as total_votes, (SELECT COUNT(*) FROM #__imc_comments WHERE state=1) as total_comments, (SELECT COUNT(*) FROM #__users WHERE 1) as total_users, + (SELECT UNIX_TIMESTAMP(created) FROM #__imc_issues WHERE state=1 ORDER BY created ASC LIMIT 1) as oldest_issue_date_ts, + (SELECT UNIX_TIMESTAMP(created) FROM #__imc_issues WHERE state=1 ORDER BY created DESC LIMIT 1) as newest_issue_date_ts, (SELECT created FROM #__imc_issues WHERE state=1 ORDER BY created ASC LIMIT 1) as oldest_issue_date, (SELECT created FROM #__imc_issues WHERE state=1 ORDER BY created DESC LIMIT 1) as newest_issue_date '); @@ -1264,7 +1266,7 @@ public static function intervals($by_step = false, $by_category = false, $ts = n WHERE a.issueid IN ( SELECT id FROM #__imc_issues AS p - WHERE p.state = 1 AND p.stepid >= '. self::getPrimaryStepId() . + WHERE p.state = 1 '. (!is_null($ts) ? ' AND p.created >= "' . $ts .'"' : ''). (!is_null($prior_to) ? ' AND p.created <= "' . $prior_to .'"' : '').' )