initEntryCountArray(); $period = parent::ENTRY_COUNT_PERIOD; // Get stats per day for the last 30 days $sql = <<prefix}entry AS e WHERE strftime('%Y%m%d', e.date, 'unixepoch') BETWEEN strftime('%Y%m%d', 'now', '-{$period} days') AND strftime('%Y%m%d', 'now', '-1 day') GROUP BY day ORDER BY day ASC SQL; $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); foreach ($res as $value) { $count[(int) $value['day']] = (int) $value['count']; } return $this->convertToSerie($count); } /** * Calculates entry average per day on a 30 days period. * * @return integer */ public function calculateEntryAverage() { $period = self::ENTRY_COUNT_PERIOD; // Get stats per day for the last 30 days $sql = <<prefix}entry AS e WHERE strftime('%Y%m%d', e.date, 'unixepoch') BETWEEN strftime('%Y%m%d', 'now', '-{$period} days') AND strftime('%Y%m%d', 'now', '-1 day') SQL; $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetch(PDO::FETCH_NAMED); return round($res['average'], 2); } protected function calculateEntryRepartitionPerFeedPerPeriod($period, $feed = null) { if ($feed) { $restrict = "WHERE e.id_feed = {$feed}"; } else { $restrict = ''; } $sql = <<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 $this->convertToSerie($repartition); } }