From e507256d0bdebd02cf1fcd6fe1477cbac0b6934e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 23 Jul 2014 00:24:00 +0200 Subject: Stats idle feed small bug Some feeds were listed more than once. A bit more independent from the SQL query. https://github.com/marienfressinaud/FreshRSS/issues/544 --- app/Controllers/statsController.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'app/Controllers/statsController.php') diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index be58dd0eb..45d13e043 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -15,7 +15,13 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function idleAction() { $statsDAO = FreshRSS_Factory::createStatsDAO(); $feeds = $statsDAO->calculateFeedLastDate(); - $idleFeeds = array(); + $idleFeeds = array( + 'last_year' => array(), + 'last_6_month' => array(), + 'last_3_month' => array(), + 'last_month' => array(), + 'last_week' => array(), + ); $now = new \DateTime(); $feedDate = clone $now; $lastWeek = clone $now; @@ -34,24 +40,20 @@ class FreshRSS_stats_Controller extends Minz_ActionController { if ($feedDate >= $lastWeek) { continue; } - if ($feedDate < $lastWeek) { - $idleFeeds['last_week'][] = $feed; - } - if ($feedDate < $lastMonth) { - $idleFeeds['last_month'][] = $feed; - } - if ($feedDate < $last3Month) { - $idleFeeds['last_3_month'][] = $feed; - } - if ($feedDate < $last6Month) { - $idleFeeds['last_6_month'][] = $feed; - } if ($feedDate < $lastYear) { $idleFeeds['last_year'][] = $feed; + } elseif ($feedDate < $last6Month) { + $idleFeeds['last_6_month'][] = $feed; + } elseif ($feedDate < $last3Month) { + $idleFeeds['last_3_month'][] = $feed; + } elseif ($feedDate < $lastMonth) { + $idleFeeds['last_month'][] = $feed; + } elseif ($feedDate < $lastWeek) { + $idleFeeds['last_week'][] = $feed; } } - $this->view->idleFeeds = array_reverse($idleFeeds); + $this->view->idleFeeds = $idleFeeds; } public function firstAction() { -- cgit v1.2.3