StatsDAOSQLite.php 702 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO {
  3. protected function calculateEntryRepartitionPerFeedPerPeriod($period, $feed = null) {
  4. if ($feed) {
  5. $restrict = "WHERE e.id_feed = {$feed}";
  6. } else {
  7. $restrict = '';
  8. }
  9. $sql = <<<SQL
  10. SELECT strftime('{$period}', e.date, 'unixepoch') AS period
  11. , COUNT(1) AS count
  12. FROM {$this->prefix}entry AS e
  13. {$restrict}
  14. GROUP BY period
  15. ORDER BY period ASC
  16. SQL;
  17. $stm = $this->bd->prepare($sql);
  18. $stm->execute();
  19. $res = $stm->fetchAll(PDO::FETCH_NAMED);
  20. $repartition = array();
  21. foreach ($res as $value) {
  22. $repartition[(int) $value['period']] = (int) $value['count'];
  23. }
  24. return $this->convertToSerie($repartition);
  25. }
  26. }