mirror of
https://github.com/flarum/core.git
synced 2025-08-14 04:14:06 +02:00
feat: add support for SQLite
(#3984)
* feat: add support for sqlite * chore: add warning on install * fix: ignore constraints before transaction begins * chore: update workflow * Apply fixes from StyleCI * chore: generate sqlite dump and manually add foreign keys * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * chore: fix actions * test: fix * Apply fixes from StyleCI * fix: sqlite with db prefix * Apply fixes from StyleCI * fix: statistics sqlite
This commit is contained in:
@@ -130,12 +130,16 @@ class ShowStatisticsData implements RequestHandlerInterface
|
||||
$endDate = new DateTime();
|
||||
}
|
||||
|
||||
// if within the last 24 hours, group by hour
|
||||
$format = 'CASE WHEN '.$column.' > ? THEN \'%Y-%m-%d %H:00:00\' ELSE \'%Y-%m-%d\' END';
|
||||
$dbFormattedDatetime = match ($query->getConnection()->getDriverName()) {
|
||||
'sqlite' => 'strftime('.$format.', '.$column.')',
|
||||
default => 'DATE_FORMAT('.$column.', '.$format.')',
|
||||
};
|
||||
|
||||
$results = $query
|
||||
->selectRaw(
|
||||
'DATE_FORMAT(
|
||||
@date := '.$column.',
|
||||
IF(@date > ?, \'%Y-%m-%d %H:00:00\', \'%Y-%m-%d\') -- if within the last 24 hours, group by hour
|
||||
) as time_group',
|
||||
$dbFormattedDatetime.' as time_group',
|
||||
[new DateTime('-25 hours')]
|
||||
)
|
||||
->selectRaw('COUNT(id) as count')
|
||||
|
@@ -102,7 +102,7 @@ class CanRequestCustomTimedStatisticsTest extends TestCase
|
||||
|
||||
$body = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals(200, $response->getStatusCode(), $body['errors'][0]['detail'] ?? '');
|
||||
|
||||
$this->assertEquals(
|
||||
$data,
|
||||
|
Reference in New Issue
Block a user