diff options
| author | 2014-07-21 18:00:32 +0200 | |
|---|---|---|
| committer | 2014-07-21 18:00:32 +0200 | |
| commit | 8d7ac978f9af4819fc788e7e0a514dc7ca9886d9 (patch) | |
| tree | fcc7e399a5f628a904518b7b522b17cef67a76e1 /app/Models/StatsDAOSQLite.php | |
| parent | a4dac0f791ae6d34b64cee5a3fae1815f6f70a2b (diff) | |
| parent | 73bbdaa015ec8596603fa88bd2cb03f85548e05e (diff) | |
Merge branch 'dev' into beta
Diffstat (limited to 'app/Models/StatsDAOSQLite.php')
| -rw-r--r-- | app/Models/StatsDAOSQLite.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php new file mode 100644 index 000000000..dea590c92 --- /dev/null +++ b/app/Models/StatsDAOSQLite.php @@ -0,0 +1,37 @@ +<?php + +class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { + + /** + * Calculates entry count per day on a 30 days period. + * Returns the result as a JSON string. + * + * @return string + */ + public function calculateEntryCount() { + $count = $this->initEntryCountArray(); + $period = parent::ENTRY_COUNT_PERIOD; + + // Get stats per day for the last 30 days + $sql = <<<SQL +SELECT round(julianday(e.date, 'unixepoch') - julianday('now')) AS day, +COUNT(1) AS count +FROM {$this->prefix}entry AS e +WHERE strftime('%Y%m%d', e.date, 'unixepoch') + BETWEEN strftime('%Y%m%d', 'now', '-{$period} days') + AND strftime('%Y%m%d', 'now', '-1 day') +GROUP BY day +ORDER BY day ASC +SQL; + $stm = $this->bd->prepare($sql); + $stm->execute(); + $res = $stm->fetchAll(PDO::FETCH_ASSOC); + + foreach ($res as $value) { + $count[(int)$value['day']] = (int) $value['count']; + } + + return $this->convertToSerie($count); + } + +} |
