aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/statsController.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-07-21 18:00:32 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-07-21 18:00:32 +0200
commit8d7ac978f9af4819fc788e7e0a514dc7ca9886d9 (patch)
treefcc7e399a5f628a904518b7b522b17cef67a76e1 /app/Controllers/statsController.php
parenta4dac0f791ae6d34b64cee5a3fae1815f6f70a2b (diff)
parent73bbdaa015ec8596603fa88bd2cb03f85548e05e (diff)
Merge branch 'dev' into beta
Diffstat (limited to 'app/Controllers/statsController.php')
-rw-r--r--app/Controllers/statsController.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
new file mode 100644
index 000000000..9009468bc
--- /dev/null
+++ b/app/Controllers/statsController.php
@@ -0,0 +1,67 @@
+<?php
+
+class FreshRSS_stats_Controller extends Minz_ActionController {
+
+ public function indexAction() {
+ $statsDAO = FreshRSS_Factory::createStatsDAO();
+ 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() {
+ $statsDAO = FreshRSS_Factory::createStatsDAO();
+ $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'];
+ }
+ }
+
+ $this->view->idleFeeds = array_reverse($idleFeeds);
+ }
+
+ public function firstAction() {
+ if (!$this->view->loginOk) {
+ Minz_Error::error(
+ 403, array('error' => array(Minz_Translate::t('access_denied')))
+ );
+ }
+
+ Minz_View::prependTitle(Minz_Translate::t('stats') . ' ยท ');
+ }
+
+}