aboutsummaryrefslogtreecommitdiff
path: root/app/Models/StatsDAOSQLite.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2014-07-24 22:57:31 -0400
committerGravatar Alexis Degrugillier <github@ainw.org> 2014-07-24 22:57:31 -0400
commitaa317eb2948b5caa5472bf307099efe850f7b314 (patch)
tree7c0e1d413e8632c66e5d8f35cd7dc018d93bea6b /app/Models/StatsDAOSQLite.php
parentd049c1bc806dc0677a4b2b17faf06080600c372f (diff)
Add repartition statistic support in Sqlite
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);
+ }
+
}