aboutsummaryrefslogtreecommitdiff
path: root/app/Models/StatsDAOSQLite.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-24 15:29:09 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-24 15:29:09 +0200
commit07444280d1a03daa7880c1539bde3a6e80945dab (patch)
treec328a11f59e07d12e624576ed86b11ada1b9d198 /app/Models/StatsDAOSQLite.php
parent1d2527b8bc2a125cc8b8508402417f60d314e330 (diff)
parentd1f79fee69a3667913f419cd9726ffb11f410bd0 (diff)
Merge branch 'dev' into beta
Conflicts: README.md
Diffstat (limited to 'app/Models/StatsDAOSQLite.php')
-rw-r--r--app/Models/StatsDAOSQLite.php28
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);
+ }
+
}