Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions site/controllers/api.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion site/helpers/imc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
');
Expand Down Expand Up @@ -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 .'"' : '').'
)
Expand Down