From 354a048235475b5f642814e38aa445279f9ba665 Mon Sep 17 00:00:00 2001 From: Tasos Papazoglou - Chalikias Date: Thu, 12 Jan 2017 14:20:01 +0200 Subject: [PATCH 1/2] GET Intervals (Analytics): Changed call to return data that have the initial-default step when called with "order by step & cat" = true. --- site/helpers/imc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/helpers/imc.php b/site/helpers/imc.php index b8e5a8f..9eeedcc 100644 --- a/site/helpers/imc.php +++ b/site/helpers/imc.php @@ -1264,7 +1264,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 AND p.stepid >= '. self::getPrimaryStepId() . (!is_null($ts) ? ' AND p.created >= "' . $ts .'"' : ''). (!is_null($prior_to) ? ' AND p.created <= "' . $prior_to .'"' : '').' ) From e183b1b6113a53fe05b9c47090a180c7dc0699b9 Mon Sep 17 00:00:00 2001 From: Tasos Papazoglou - Chalikias Date: Fri, 13 Jan 2017 17:23:33 +0200 Subject: [PATCH 2/2] Analytics related changes in Intervals() & Totals(). --- site/controllers/api.json.php | 7 +++++++ site/helpers/imc.php | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 .'"' : '').' )