diff options
| author | 2014-07-29 00:07:07 +0200 | |
|---|---|---|
| committer | 2014-07-29 00:07:07 +0200 | |
| commit | 4a0e5ac037dc3c8fd16ca086924087f8ccaed46b (patch) | |
| tree | 40b19d8c2ee769f0ca719f4ac00e9868d20bdb99 /app/Models/StatsDAOSQLite.php | |
| parent | 1d73286aaa05e95669ffdf27538424a0c6504b8f (diff) | |
| parent | 1739e2e9d2f6b46ee7de81322f282b4ef4f0dddd (diff) | |
Merge pull request #548 from aledeg/more-stats
Add article repartition in stats
Diffstat (limited to 'app/Models/StatsDAOSQLite.php')
| -rw-r--r-- | app/Models/StatsDAOSQLite.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php index dea590c92..6cb54ddf6 100644 --- a/app/Models/StatsDAOSQLite.php +++ b/app/Models/StatsDAOSQLite.php @@ -28,10 +28,36 @@ SQL; $res = $stm->fetchAll(PDO::FETCH_ASSOC); foreach ($res as $value) { - $count[(int)$value['day']] = (int) $value['count']; + $count[(int) $value['day']] = (int) $value['count']; } return $this->convertToSerie($count); } + 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); + + foreach ($res as $value) { + $repartition[(int) $value['period']] = (int) $value['count']; + } + + return $this->convertToSerie($repartition); + } + } |
