aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/statsController.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-06-15 12:13:33 -0400
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-06-15 12:13:33 -0400
commit60fe99344e1d87850f1a44791c1f0a675d13c756 (patch)
tree272ebbc35d0c28b4b049cb10a4e8868e12f808a8 /app/Controllers/statsController.php
parente9cee8cc20835b3151de70e4df25cc5e80c4ec85 (diff)
Refactor and formatting
Diffstat (limited to 'app/Controllers/statsController.php')
-rw-r--r--app/Controllers/statsController.php100
1 files changed, 48 insertions, 52 deletions
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();
+ }
- $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');
+ 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');
- 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') . ' · ');
}
}