mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-06 22:23:10 -04:00
Add repartition statistic support in Sqlite
This commit is contained in:
@@ -95,7 +95,7 @@ SQL;
|
||||
* @return string
|
||||
*/
|
||||
public function calculateEntryRepartitionPerFeedPerHour($feed = null) {
|
||||
return $this->calculateEntryRepartitionPerFeedPerPeriod('%k', $feed);
|
||||
return $this->calculateEntryRepartitionPerFeedPerPeriod('%H', $feed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user