aboutsummaryrefslogtreecommitdiff
path: root/app/Models/StatsDAOSQLite.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-10-14 11:05:17 +0200
committerGravatar GitHub <noreply@github.com> 2025-10-14 11:05:17 +0200
commit5eba322cbd24191e05304df08c80af846977d99b (patch)
tree6f41386abfc77937fb042e48ca061e6dc0d2a7a5 /app/Models/StatsDAOSQLite.php
parent20ecbeb09cdf05ca3ffd44980e9070b34c2b71ec (diff)
New stats overview of dates with most unread articles (#8089)
New view with direct links to dates with most unread articles: <img width="734" height="581" alt="image" src="https://github.com/user-attachments/assets/159a39b3-3a06-4ae9-9cc0-62ae36d9db9c" />
Diffstat (limited to 'app/Models/StatsDAOSQLite.php')
-rw-r--r--app/Models/StatsDAOSQLite.php14
1 files changed, 13 insertions, 1 deletions
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
@@ -4,6 +4,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 = <<<SQL
-SELECT strftime('{$period}', e.date, 'unixepoch') AS period
+SELECT strftime('{$period}', e.date + {$offset}, 'unixepoch') AS period
, COUNT(1) AS count
FROM `_entry` AS e
{$restrict}