diff options
| author | 2014-07-06 11:54:00 +0200 | |
|---|---|---|
| committer | 2014-07-06 11:54:00 +0200 | |
| commit | 3bbd0e446f6a1a0c41a4db36d2841db36dc34004 (patch) | |
| tree | 7a6417f0a01d5c318112fbf0419f53c5beae61c6 /app | |
| parent | 96057fe491412171f4ef2079d3d84cbe1a61e300 (diff) | |
Prepare statistics for SQLite
Temporarily disable 30-day statistics for SQLite
https://github.com/marienfressinaud/FreshRSS/issues/100
https://github.com/marienfressinaud/FreshRSS/issues/90
Diffstat (limited to 'app')
| -rw-r--r-- | app/Controllers/statsController.php | 4 | ||||
| -rw-r--r-- | app/Models/Factory.php | 10 | ||||
| -rw-r--r-- | app/Models/StatsDAO.php | 4 | ||||
| -rw-r--r-- | app/Models/StatsDAOSQLite.php | 9 |
4 files changed, 23 insertions, 4 deletions
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index fb5609cb4..9009468bc 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -3,7 +3,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function indexAction() { - $statsDAO = new FreshRSS_StatsDAO (); + $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()); @@ -13,7 +13,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { } public function idleAction() { - $statsDAO = new FreshRSS_StatsDAO (); + $statsDAO = FreshRSS_Factory::createStatsDAO(); $feeds = $statsDAO->calculateFeedLastDate(); $idleFeeds = array(); $now = new \DateTime(); diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 95d21a277..08569b2e2 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -19,4 +19,14 @@ class FreshRSS_Factory { return new FreshRSS_EntryDAO(); } } + + public static function createStatsDAO() { + $db = Minz_Configuration::dataBase(); + if ($db['type'] === 'sqlite') { + return new FreshRSS_StatsDAOSQLite(); + } else { + return new FreshRSS_StatsDAO(); + } + } + } diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index eafe86407..62f238bd2 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -201,7 +201,7 @@ SQL; return $stm->fetchAll(PDO::FETCH_ASSOC); } - private function convertToSerie($data) { + protected function convertToSerie($data) { $serie = array(); foreach ($data as $key => $value) { @@ -211,7 +211,7 @@ SQL; return json_encode($serie); } - private function convertToPieSerie($data) { + protected function convertToPieSerie($data) { $serie = array(); foreach ($data as $value) { diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php new file mode 100644 index 000000000..c923e5fd0 --- /dev/null +++ b/app/Models/StatsDAOSQLite.php @@ -0,0 +1,9 @@ +<?php + +class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { + + public function calculateEntryCount() { + return $this->convertToSerie(array()); //TODO: Implement 30-day statistics for SQLite + } + +} |
