From ef4961fe8570df97e19f70562837694f07062b2b Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 13 Jun 2014 01:00:27 -0400 Subject: [PATCH 1/7] Refactor statistics I made a new controller to handle statistics. The old statistics have been moved in that controller and a new action has been added to display idle feeds. I also added a menu in the left panel to navigate between the statistics pages. See #90 --- app/Controllers/indexController.php | 19 ----- app/Controllers/statsController.php | 73 +++++++++++++++++++ app/Models/StatsDAO.php | 20 +++++ app/i18n/en.php | 8 ++ app/i18n/fr.php | 8 ++ app/layout/aside_stats.phtml | 9 +++ app/layout/header.phtml | 2 +- app/views/stats/idle.phtml | 57 +++++++++++++++ .../{index/stats.phtml => stats/main.phtml} | 12 +-- 9 files changed, 183 insertions(+), 25 deletions(-) create mode 100644 app/Controllers/statsController.php create mode 100644 app/layout/aside_stats.phtml create mode 100644 app/views/stats/idle.phtml rename app/views/{index/stats.phtml => stats/main.phtml} (94%) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 3445c0bd4..67e0181b5 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -203,25 +203,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - public function statsAction () { - if (!$this->view->loginOk) { - Minz_Error::error ( - 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) - ); - } - - Minz_View::prependTitle (Minz_Translate::t ('stats') . ' · '); - - $statsDAO = new FreshRSS_StatsDAO (); - Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); - $this->view->repartition = $statsDAO->calculateEntryRepartition(); - $this->view->count = ($statsDAO->calculateEntryCount()); - $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); - $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); - $this->view->topFeed = $statsDAO->calculateTopFeed(); - } - public function aboutAction () { Minz_View::prependTitle (Minz_Translate::t ('about') . ' · '); } diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php new file mode 100644 index 000000000..cb8870fa9 --- /dev/null +++ b/app/Controllers/statsController.php @@ -0,0 +1,73 @@ +view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + + $statsDAO = new FreshRSS_StatsDAO (); + Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); + $this->view->repartition = $statsDAO->calculateEntryRepartition(); + $this->view->count = ($statsDAO->calculateEntryCount()); + $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); + $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); + $this->view->topFeed = $statsDAO->calculateTopFeed(); + } + + public function idleAction() { + if (!$this->view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + + $statsDAO = new FreshRSS_StatsDAO (); + $feeds = $statsDAO->calculateFeedLastDate(); + $idleFeeds = array(); + $now = new \DateTime(); + $feedDate = clone $now; + $lastWeek = clone $now; + $lastWeek->modify('-1 week'); + $lastMonth = clone $now; + $lastMonth->modify('-1 month'); + $last3Month = clone $now; + $last3Month->modify('-3 month'); + $last6Month = clone $now; + $last6Month->modify('-6 month'); + $lastYear = clone $now; + $lastYear->modify('-1 year'); + + foreach ($feeds as $feed) { + $feedDate->setTimestamp($feed['last_date']); + if ($feedDate >= $lastWeek) { + continue; + } + if ($feedDate < $lastWeek) { + $idleFeeds['lastWeek'][] = $feed['name']; + } + if ($feedDate < $lastMonth) { + $idleFeeds['lastMonth'][] = $feed['name']; + } + if ($feedDate < $last3Month) { + $idleFeeds['last3Month'][] = $feed['name']; + } + if ($feedDate < $last6Month) { + $idleFeeds['last6Month'][] = $feed['name']; + } + if ($feedDate < $lastYear) { + $idleFeeds['lastYear'][] = $feed['name']; + } + } + + $this->view->idleFeeds = $idleFeeds; + } + +} diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 60cec7847..f9f4740fd 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -180,6 +180,26 @@ SQL; $stm->execute(); return $stm->fetchAll(PDO::FETCH_ASSOC); } + + /** + * Calculates the last publication date for each feed + * + * @return array + */ + public function calculateFeedLastDate() { + $sql = <<prefix}feed AS f, +{$this->prefix}entry AS e +WHERE f.id = e.id_feed +GROUP BY f.id +ORDER BY name +SQL; + $stm = $this->bd->prepare($sql); + $stm->execute(); + return $stm->fetchAll(PDO::FETCH_ASSOC); + } private function convertToSerie($data) { $serie = array(); diff --git a/app/i18n/en.php b/app/i18n/en.php index a3c1dfeb7..4f6b9ee97 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -17,6 +17,14 @@ return array ( 'shortcuts' => 'Shortcuts', 'about' => 'About', 'stats' => 'Statistics', + 'stats_idle' => 'Idle feeds', + 'stats_main' => 'Main statistics', + + 'last_week' => 'Last week', + 'last_month' => 'Last month', + 'last_3_month' => 'Last three months', + 'last_6_month' => 'Last six months', + 'last_year' => 'Last year', 'your_rss_feeds' => 'Your RSS feeds', 'add_rss_feed' => 'Add a RSS feed', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 4acf5b397..e29b2bfb9 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -17,6 +17,14 @@ return array ( 'shortcuts' => 'Raccourcis', 'about' => 'À propos', 'stats' => 'Statistiques', + 'stats_idle' => 'Flux inactifs', + 'stats_main' => 'Statistiques principales', + + 'last_week' => 'La dernière semaine', + 'last_month' => 'Le dernier mois', + 'last_3_month' => 'Les derniers trois mois', + 'last_6_month' => 'Les derniers six mois', + 'last_year' => 'La dernière année', 'your_rss_feeds' => 'Vos flux RSS', 'add_rss_feed' => 'Ajouter un flux RSS', diff --git a/app/layout/aside_stats.phtml b/app/layout/aside_stats.phtml new file mode 100644 index 000000000..bc1e85592 --- /dev/null +++ b/app/layout/aside_stats.phtml @@ -0,0 +1,9 @@ + diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 08aa7715d..9bebb30e8 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -75,7 +75,7 @@ if (Minz_Configuration::canLogIn()) {
  • -
  • +
  • partial('aside_stats'); ?> + +
    + + +

    + +
    +

    + +
      + idleFeeds['lastWeek'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['lastMonth'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['last3Month'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['last6Month'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['lastYear'] as $feed): ?> +
    • + +
    +
    +
    \ No newline at end of file diff --git a/app/views/index/stats.phtml b/app/views/stats/main.phtml similarity index 94% rename from app/views/index/stats.phtml rename to app/views/stats/main.phtml index b5c18813d..fe372e221 100644 --- a/app/views/index/stats.phtml +++ b/app/views/stats/main.phtml @@ -1,9 +1,11 @@ +partial('aside_stats'); ?> +
    - - -

    - -
    + + +

    + +

    From 1affa91312e9edc23e11f9454190dd5c35c9adf8 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 13 Jun 2014 18:19:09 -0400 Subject: [PATCH 2/7] Refactor idle feed stats --- app/Controllers/statsController.php | 12 +++--- app/views/stats/idle.phtml | 58 +++++------------------------ 2 files changed, 16 insertions(+), 54 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index cb8870fa9..655d453c6 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -51,23 +51,23 @@ class FreshRSS_stats_Controller extends Minz_ActionController { continue; } if ($feedDate < $lastWeek) { - $idleFeeds['lastWeek'][] = $feed['name']; + $idleFeeds['last_week'][] = $feed['name']; } if ($feedDate < $lastMonth) { - $idleFeeds['lastMonth'][] = $feed['name']; + $idleFeeds['last_month'][] = $feed['name']; } if ($feedDate < $last3Month) { - $idleFeeds['last3Month'][] = $feed['name']; + $idleFeeds['last_3_month'][] = $feed['name']; } if ($feedDate < $last6Month) { - $idleFeeds['last6Month'][] = $feed['name']; + $idleFeeds['last_6_month'][] = $feed['name']; } if ($feedDate < $lastYear) { - $idleFeeds['lastYear'][] = $feed['name']; + $idleFeeds['last_year'][] = $feed['name']; } } - $this->view->idleFeeds = $idleFeeds; + $this->view->idleFeeds = array_reverse($idleFeeds); } } diff --git a/app/views/stats/idle.phtml b/app/views/stats/idle.phtml index 5c11b3f86..08ce440e8 100644 --- a/app/views/stats/idle.phtml +++ b/app/views/stats/idle.phtml @@ -5,53 +5,15 @@

    -
    -

    + idleFeeds as $period => $feeds): ?> +
    +

    -
      - idleFeeds['lastWeek'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['lastMonth'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['last3Month'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['last6Month'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['lastYear'] as $feed): ?> -
    • - -
    -
    +
      + +
    • + +
    +
    + \ No newline at end of file From 177b398784da22854d39a1790514353f41a97450 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 15 Jun 2014 11:48:08 -0400 Subject: [PATCH 3/7] Fix syntax --- app/Controllers/statsController.php | 26 ++++++++++++-------------- app/views/stats/idle.phtml | 10 +++++----- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 655d453c6..cbc67cac3 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -3,13 +3,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function mainAction() { - if (!$this->view->loginOk) { - Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) - ); - } - - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + $this->initAction(); $statsDAO = new FreshRSS_StatsDAO (); Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); @@ -21,13 +15,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { } public function idleAction() { - if (!$this->view->loginOk) { - Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) - ); - } - - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + $this->initAction(); $statsDAO = new FreshRSS_StatsDAO (); $feeds = $statsDAO->calculateFeedLastDate(); @@ -69,5 +57,15 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $this->view->idleFeeds = array_reverse($idleFeeds); } + + private function initAction() { + if (!$this->view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + } } diff --git a/app/views/stats/idle.phtml b/app/views/stats/idle.phtml index 08ce440e8..26806bb0e 100644 --- a/app/views/stats/idle.phtml +++ b/app/views/stats/idle.phtml @@ -5,15 +5,15 @@

    - idleFeeds as $period => $feeds): ?> + idleFeeds as $period => $feeds){ ?>

      - +
    • - +
    - - \ No newline at end of file + + From 181fcd98893f65a2c5159158fbfc022b4661ea13 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 13 Jun 2014 01:00:27 -0400 Subject: [PATCH 4/7] Refactor statistics I made a new controller to handle statistics. The old statistics have been moved in that controller and a new action has been added to display idle feeds. I also added a menu in the left panel to navigate between the statistics pages. See #90 --- app/Controllers/indexController.php | 19 ----- app/Controllers/statsController.php | 73 +++++++++++++++++++ app/Models/StatsDAO.php | 20 +++++ app/i18n/en.php | 8 ++ app/i18n/fr.php | 8 ++ app/layout/aside_stats.phtml | 9 +++ app/layout/header.phtml | 2 +- app/views/stats/idle.phtml | 57 +++++++++++++++ .../{index/stats.phtml => stats/main.phtml} | 12 +-- 9 files changed, 183 insertions(+), 25 deletions(-) create mode 100644 app/Controllers/statsController.php create mode 100644 app/layout/aside_stats.phtml create mode 100644 app/views/stats/idle.phtml rename app/views/{index/stats.phtml => stats/main.phtml} (94%) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 4fcc3176f..daf9fb95a 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -198,25 +198,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - public function statsAction () { - if (!$this->view->loginOk) { - Minz_Error::error ( - 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) - ); - } - - Minz_View::prependTitle (Minz_Translate::t ('stats') . ' · '); - - $statsDAO = new FreshRSS_StatsDAO (); - Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); - $this->view->repartition = $statsDAO->calculateEntryRepartition(); - $this->view->count = ($statsDAO->calculateEntryCount()); - $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); - $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); - $this->view->topFeed = $statsDAO->calculateTopFeed(); - } - public function aboutAction () { Minz_View::prependTitle (Minz_Translate::t ('about') . ' · '); } diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php new file mode 100644 index 000000000..cb8870fa9 --- /dev/null +++ b/app/Controllers/statsController.php @@ -0,0 +1,73 @@ +view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + + $statsDAO = new FreshRSS_StatsDAO (); + Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); + $this->view->repartition = $statsDAO->calculateEntryRepartition(); + $this->view->count = ($statsDAO->calculateEntryCount()); + $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); + $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); + $this->view->topFeed = $statsDAO->calculateTopFeed(); + } + + public function idleAction() { + if (!$this->view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + + $statsDAO = new FreshRSS_StatsDAO (); + $feeds = $statsDAO->calculateFeedLastDate(); + $idleFeeds = array(); + $now = new \DateTime(); + $feedDate = clone $now; + $lastWeek = clone $now; + $lastWeek->modify('-1 week'); + $lastMonth = clone $now; + $lastMonth->modify('-1 month'); + $last3Month = clone $now; + $last3Month->modify('-3 month'); + $last6Month = clone $now; + $last6Month->modify('-6 month'); + $lastYear = clone $now; + $lastYear->modify('-1 year'); + + foreach ($feeds as $feed) { + $feedDate->setTimestamp($feed['last_date']); + if ($feedDate >= $lastWeek) { + continue; + } + if ($feedDate < $lastWeek) { + $idleFeeds['lastWeek'][] = $feed['name']; + } + if ($feedDate < $lastMonth) { + $idleFeeds['lastMonth'][] = $feed['name']; + } + if ($feedDate < $last3Month) { + $idleFeeds['last3Month'][] = $feed['name']; + } + if ($feedDate < $last6Month) { + $idleFeeds['last6Month'][] = $feed['name']; + } + if ($feedDate < $lastYear) { + $idleFeeds['lastYear'][] = $feed['name']; + } + } + + $this->view->idleFeeds = $idleFeeds; + } + +} diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 60cec7847..f9f4740fd 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -180,6 +180,26 @@ SQL; $stm->execute(); return $stm->fetchAll(PDO::FETCH_ASSOC); } + + /** + * Calculates the last publication date for each feed + * + * @return array + */ + public function calculateFeedLastDate() { + $sql = <<prefix}feed AS f, +{$this->prefix}entry AS e +WHERE f.id = e.id_feed +GROUP BY f.id +ORDER BY name +SQL; + $stm = $this->bd->prepare($sql); + $stm->execute(); + return $stm->fetchAll(PDO::FETCH_ASSOC); + } private function convertToSerie($data) { $serie = array(); diff --git a/app/i18n/en.php b/app/i18n/en.php index c0eb5a2bf..8d5f305c0 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -46,6 +46,14 @@ return array ( 'no_query_filter' => 'No filter', 'about' => 'About', 'stats' => 'Statistics', + 'stats_idle' => 'Idle feeds', + 'stats_main' => 'Main statistics', + + 'last_week' => 'Last week', + 'last_month' => 'Last month', + 'last_3_month' => 'Last three months', + 'last_6_month' => 'Last six months', + 'last_year' => 'Last year', 'your_rss_feeds' => 'Your RSS feeds', 'add_rss_feed' => 'Add a RSS feed', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 0cabf02c1..3441425df 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -46,6 +46,14 @@ return array ( 'no_query_filter' => 'Aucun filtre appliqué', 'about' => 'À propos', 'stats' => 'Statistiques', + 'stats_idle' => 'Flux inactifs', + 'stats_main' => 'Statistiques principales', + + 'last_week' => 'La dernière semaine', + 'last_month' => 'Le dernier mois', + 'last_3_month' => 'Les derniers trois mois', + 'last_6_month' => 'Les derniers six mois', + 'last_year' => 'La dernière année', 'your_rss_feeds' => 'Vos flux RSS', 'add_rss_feed' => 'Ajouter un flux RSS', diff --git a/app/layout/aside_stats.phtml b/app/layout/aside_stats.phtml new file mode 100644 index 000000000..bc1e85592 --- /dev/null +++ b/app/layout/aside_stats.phtml @@ -0,0 +1,9 @@ + diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 3eedc8ea7..3be3e496d 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -76,7 +76,7 @@ if (Minz_Configuration::canLogIn()) {
  • -
  • +
  • partial('aside_stats'); ?> + +
    + + +

    + +
    +

    + +
      + idleFeeds['lastWeek'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['lastMonth'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['last3Month'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['last6Month'] as $feed): ?> +
    • + +
    +
    + +
    +

    + +
      + idleFeeds['lastYear'] as $feed): ?> +
    • + +
    +
    +
    \ No newline at end of file diff --git a/app/views/index/stats.phtml b/app/views/stats/main.phtml similarity index 94% rename from app/views/index/stats.phtml rename to app/views/stats/main.phtml index b5c18813d..fe372e221 100644 --- a/app/views/index/stats.phtml +++ b/app/views/stats/main.phtml @@ -1,9 +1,11 @@ +partial('aside_stats'); ?> +
    - - -

    - -
    + + +

    + +

    From d9f570a84d32921287fadced6dce0304b565bb85 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 13 Jun 2014 18:19:09 -0400 Subject: [PATCH 5/7] Refactor idle feed stats --- app/Controllers/statsController.php | 12 +++--- app/views/stats/idle.phtml | 58 +++++------------------------ 2 files changed, 16 insertions(+), 54 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index cb8870fa9..655d453c6 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -51,23 +51,23 @@ class FreshRSS_stats_Controller extends Minz_ActionController { continue; } if ($feedDate < $lastWeek) { - $idleFeeds['lastWeek'][] = $feed['name']; + $idleFeeds['last_week'][] = $feed['name']; } if ($feedDate < $lastMonth) { - $idleFeeds['lastMonth'][] = $feed['name']; + $idleFeeds['last_month'][] = $feed['name']; } if ($feedDate < $last3Month) { - $idleFeeds['last3Month'][] = $feed['name']; + $idleFeeds['last_3_month'][] = $feed['name']; } if ($feedDate < $last6Month) { - $idleFeeds['last6Month'][] = $feed['name']; + $idleFeeds['last_6_month'][] = $feed['name']; } if ($feedDate < $lastYear) { - $idleFeeds['lastYear'][] = $feed['name']; + $idleFeeds['last_year'][] = $feed['name']; } } - $this->view->idleFeeds = $idleFeeds; + $this->view->idleFeeds = array_reverse($idleFeeds); } } diff --git a/app/views/stats/idle.phtml b/app/views/stats/idle.phtml index 5c11b3f86..08ce440e8 100644 --- a/app/views/stats/idle.phtml +++ b/app/views/stats/idle.phtml @@ -5,53 +5,15 @@

    -
    -

    + idleFeeds as $period => $feeds): ?> +
    +

    -
      - idleFeeds['lastWeek'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['lastMonth'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['last3Month'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['last6Month'] as $feed): ?> -
    • - -
    -
    - -
    -

    - -
      - idleFeeds['lastYear'] as $feed): ?> -
    • - -
    -
    +
      + +
    • + +
    +
    + \ No newline at end of file From e9cee8cc20835b3151de70e4df25cc5e80c4ec85 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 15 Jun 2014 11:48:08 -0400 Subject: [PATCH 6/7] Fix syntax --- app/Controllers/statsController.php | 26 ++++++++++++-------------- app/views/stats/idle.phtml | 10 +++++----- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 655d453c6..cbc67cac3 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -3,13 +3,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function mainAction() { - if (!$this->view->loginOk) { - Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) - ); - } - - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + $this->initAction(); $statsDAO = new FreshRSS_StatsDAO (); Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); @@ -21,13 +15,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { } public function idleAction() { - if (!$this->view->loginOk) { - Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) - ); - } - - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + $this->initAction(); $statsDAO = new FreshRSS_StatsDAO (); $feeds = $statsDAO->calculateFeedLastDate(); @@ -69,5 +57,15 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $this->view->idleFeeds = array_reverse($idleFeeds); } + + private function initAction() { + if (!$this->view->loginOk) { + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } + + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + } } diff --git a/app/views/stats/idle.phtml b/app/views/stats/idle.phtml index 08ce440e8..26806bb0e 100644 --- a/app/views/stats/idle.phtml +++ b/app/views/stats/idle.phtml @@ -5,15 +5,15 @@

    - idleFeeds as $period => $feeds): ?> + idleFeeds as $period => $feeds){ ?>

      - +
    • - +
    - - \ No newline at end of file + + From 60fe99344e1d87850f1a44791c1f0a675d13c756 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 15 Jun 2014 12:13:33 -0400 Subject: [PATCH 7/7] Refactor and formatting --- app/Controllers/statsController.php | 100 ++++++++++---------- app/Models/StatsDAO.php | 24 ++--- app/i18n/en.php | 14 +-- app/i18n/fr.php | 14 +-- app/layout/aside_stats.phtml | 4 +- app/layout/header.phtml | 2 +- app/views/stats/idle.phtml | 24 ++--- app/views/stats/{main.phtml => index.phtml} | 36 +++---- 8 files changed, 107 insertions(+), 111 deletions(-) rename app/views/stats/{main.phtml => index.phtml} (76%) diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index cbc67cac3..fb5609cb4 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -2,70 +2,66 @@ class FreshRSS_stats_Controller extends Minz_ActionController { - public function mainAction() { - $this->initAction(); - - $statsDAO = new FreshRSS_StatsDAO (); + public function indexAction() { + $statsDAO = new FreshRSS_StatsDAO (); Minz_View::appendScript (Minz_Url::display ('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); $this->view->repartition = $statsDAO->calculateEntryRepartition(); $this->view->count = ($statsDAO->calculateEntryCount()); $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); $this->view->topFeed = $statsDAO->calculateTopFeed(); - } + } - public function idleAction() { - $this->initAction(); + public function idleAction() { + $statsDAO = new FreshRSS_StatsDAO (); + $feeds = $statsDAO->calculateFeedLastDate(); + $idleFeeds = array(); + $now = new \DateTime(); + $feedDate = clone $now; + $lastWeek = clone $now; + $lastWeek->modify('-1 week'); + $lastMonth = clone $now; + $lastMonth->modify('-1 month'); + $last3Month = clone $now; + $last3Month->modify('-3 month'); + $last6Month = clone $now; + $last6Month->modify('-6 month'); + $lastYear = clone $now; + $lastYear->modify('-1 year'); - $statsDAO = new FreshRSS_StatsDAO (); - $feeds = $statsDAO->calculateFeedLastDate(); - $idleFeeds = array(); - $now = new \DateTime(); - $feedDate = clone $now; - $lastWeek = clone $now; - $lastWeek->modify('-1 week'); - $lastMonth = clone $now; - $lastMonth->modify('-1 month'); - $last3Month = clone $now; - $last3Month->modify('-3 month'); - $last6Month = clone $now; - $last6Month->modify('-6 month'); - $lastYear = clone $now; - $lastYear->modify('-1 year'); + foreach ($feeds as $feed) { + $feedDate->setTimestamp($feed['last_date']); + if ($feedDate >= $lastWeek) { + continue; + } + if ($feedDate < $lastWeek) { + $idleFeeds['last_week'][] = $feed['name']; + } + if ($feedDate < $lastMonth) { + $idleFeeds['last_month'][] = $feed['name']; + } + if ($feedDate < $last3Month) { + $idleFeeds['last_3_month'][] = $feed['name']; + } + if ($feedDate < $last6Month) { + $idleFeeds['last_6_month'][] = $feed['name']; + } + if ($feedDate < $lastYear) { + $idleFeeds['last_year'][] = $feed['name']; + } + } - foreach ($feeds as $feed) { - $feedDate->setTimestamp($feed['last_date']); - if ($feedDate >= $lastWeek) { - continue; - } - if ($feedDate < $lastWeek) { - $idleFeeds['last_week'][] = $feed['name']; - } - if ($feedDate < $lastMonth) { - $idleFeeds['last_month'][] = $feed['name']; - } - if ($feedDate < $last3Month) { - $idleFeeds['last_3_month'][] = $feed['name']; - } - if ($feedDate < $last6Month) { - $idleFeeds['last_6_month'][] = $feed['name']; - } - if ($feedDate < $lastYear) { - $idleFeeds['last_year'][] = $feed['name']; - } - } - - $this->view->idleFeeds = array_reverse($idleFeeds); - } + $this->view->idleFeeds = array_reverse($idleFeeds); + } - private function initAction() { + public function firstAction() { if (!$this->view->loginOk) { - Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) - ); - } + Minz_Error::error( + 403, array('error' => array(Minz_Translate::t('access_denied'))) + ); + } - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); } } diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index f9f4740fd..eafe86407 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -180,14 +180,14 @@ SQL; $stm->execute(); return $stm->fetchAll(PDO::FETCH_ASSOC); } - - /** - * Calculates the last publication date for each feed - * - * @return array - */ - public function calculateFeedLastDate() { - $sql = <<prefix}feed AS f, @@ -196,10 +196,10 @@ WHERE f.id = e.id_feed GROUP BY f.id ORDER BY name SQL; - $stm = $this->bd->prepare($sql); - $stm->execute(); - return $stm->fetchAll(PDO::FETCH_ASSOC); - } + $stm = $this->bd->prepare($sql); + $stm->execute(); + return $stm->fetchAll(PDO::FETCH_ASSOC); + } private function convertToSerie($data) { $serie = array(); diff --git a/app/i18n/en.php b/app/i18n/en.php index 8d5f305c0..19cf4a06d 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -46,14 +46,14 @@ return array ( 'no_query_filter' => 'No filter', 'about' => 'About', 'stats' => 'Statistics', - 'stats_idle' => 'Idle feeds', - 'stats_main' => 'Main statistics', + 'stats_idle' => 'Idle feeds', + 'stats_main' => 'Main statistics', - 'last_week' => 'Last week', - 'last_month' => 'Last month', - 'last_3_month' => 'Last three months', - 'last_6_month' => 'Last six months', - 'last_year' => 'Last year', + 'last_week' => 'Last week', + 'last_month' => 'Last month', + 'last_3_month' => 'Last three months', + 'last_6_month' => 'Last six months', + 'last_year' => 'Last year', 'your_rss_feeds' => 'Your RSS feeds', 'add_rss_feed' => 'Add a RSS feed', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 3441425df..54fe55ea0 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -46,14 +46,14 @@ return array ( 'no_query_filter' => 'Aucun filtre appliqué', 'about' => 'À propos', 'stats' => 'Statistiques', - 'stats_idle' => 'Flux inactifs', - 'stats_main' => 'Statistiques principales', + 'stats_idle' => 'Flux inactifs', + 'stats_main' => 'Statistiques principales', - 'last_week' => 'La dernière semaine', - 'last_month' => 'Le dernier mois', - 'last_3_month' => 'Les derniers trois mois', - 'last_6_month' => 'Les derniers six mois', - 'last_year' => 'La dernière année', + 'last_week' => 'La dernière semaine', + 'last_month' => 'Le dernier mois', + 'last_3_month' => 'Les derniers trois mois', + 'last_6_month' => 'Les derniers six mois', + 'last_year' => 'La dernière année', 'your_rss_feeds' => 'Vos flux RSS', 'add_rss_feed' => 'Ajouter un flux RSS', diff --git a/app/layout/aside_stats.phtml b/app/layout/aside_stats.phtml index bc1e85592..32a3f5dee 100644 --- a/app/layout/aside_stats.phtml +++ b/app/layout/aside_stats.phtml @@ -1,7 +1,7 @@ + diff --git a/app/views/stats/main.phtml b/app/views/stats/index.phtml similarity index 76% rename from app/views/stats/main.phtml rename to app/views/stats/index.phtml index fe372e221..a48181fe4 100644 --- a/app/views/stats/main.phtml +++ b/app/views/stats/index.phtml @@ -1,38 +1,38 @@ partial('aside_stats'); ?>
    - - -

    + + +

    -
    -

    +
    +

    - - + + - + - + - + - + @@ -41,30 +41,30 @@
    -

    +

    -

    +

    -

    +

    -

    +

     
    repartition['main_stream']['total']); ?> repartition['all_feeds']['total']); ?>
    repartition['main_stream']['read']); ?> repartition['all_feeds']['read']); ?>
    repartition['main_stream']['unread']); ?> repartition['all_feeds']['unread']); ?>
    repartition['main_stream']['favorite']); ?> repartition['all_feeds']['favorite']); ?>
    - - - + + +