diff options
| author | 2017-02-15 14:14:03 +0100 | |
|---|---|---|
| committer | 2017-02-15 14:14:03 +0100 | |
| commit | 5a1bb1393b4496eb35a2ffb3cc63d41c9dc1e2e5 (patch) | |
| tree | 67028e45792c575c25c92616633f64cc7a4a13eb /app/Models/StatsDAOSQLite.php | |
| parent | 7e949d50320317b5c3b5a2da2bdaf324e794b2f7 (diff) | |
| parent | 5f637bd816b7323885bfe1751a1724ee59a822f6 (diff) | |
Merge remote-tracking branch 'FreshRSS/master'
Diffstat (limited to 'app/Models/StatsDAOSQLite.php')
| -rw-r--r-- | app/Models/StatsDAOSQLite.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php new file mode 100644 index 000000000..6cfc20463 --- /dev/null +++ b/app/Models/StatsDAOSQLite.php @@ -0,0 +1,36 @@ +<?php + +class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { + + protected function sqlFloor($s) { + return "CAST(($s) AS INT)"; + } + + protected function calculateEntryRepartitionPerFeedPerPeriod($period, $feed = null) { + if ($feed) { + $restrict = "WHERE e.id_feed = {$feed}"; + } else { + $restrict = ''; + } + $sql = <<<SQL +SELECT strftime('{$period}', e.date, 'unixepoch') AS period +, COUNT(1) AS count +FROM `{$this->prefix}entry` AS e +{$restrict} +GROUP BY period +ORDER BY period ASC +SQL; + + $stm = $this->bd->prepare($sql); + $stm->execute(); + $res = $stm->fetchAll(PDO::FETCH_NAMED); + + $repartition = array(); + foreach ($res as $value) { + $repartition[(int) $value['period']] = (int) $value['count']; + } + + return $repartition; + } + +} |
