From 5eba322cbd24191e05304df08c80af846977d99b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 14 Oct 2025 11:05:17 +0200 Subject: New stats overview of dates with most unread articles (#8089) New view with direct links to dates with most unread articles: image --- app/Models/StatsDAOSQLite.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/Models/StatsDAOSQLite.php') diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php index 4e51615fc..50b12d2c7 100644 --- a/app/Models/StatsDAOSQLite.php +++ b/app/Models/StatsDAOSQLite.php @@ -3,6 +3,17 @@ declare(strict_types=1); class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { + #[\Override] + protected function sqlDateToIsoGranularity(string $field, int $precision, string $granularity): string { + $offset = $this->getTimezoneOffset(); + return match ($granularity) { + 'day' => "strftime('%Y-%m-%d', ($field / $precision) + $offset, 'unixepoch')", + 'month' => "strftime('%Y-%m', ($field / $precision) + $offset, 'unixepoch')", + 'year' => "strftime('%Y', ($field / $precision) + $offset, 'unixepoch')", + default => throw new InvalidArgumentException('Invalid date granularity'), + }; + } + #[\Override] protected function sqlFloor(string $s): string { return "CAST(($s) AS INT)"; @@ -18,8 +29,9 @@ class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { } else { $restrict = ''; } + $offset = $this->getTimezoneOffset(); $sql = <<