Fix grouping error in PostgreSQL

This commit is contained in:
Dan Church 2021-09-27 12:00:48 -05:00
parent 4225f32af0
commit b167873632
No known key found for this signature in database
GPG key ID: EA2BF379CD2CDBD0

View file

@ -68,8 +68,8 @@ class AdminStatsService
{
$ttl = now()->addHours(12);
return Cache::remember('admin:dashboard:home:data-postsGraph:v0.1:24hr', $ttl, function() {
$gb = config('database.default') == 'pgsql' ? ['statuses.id', DB::raw('Date(created_at)')] : DB::raw('Date(created_at)');
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count, statuses.*')
$gb = config('database.default') == 'pgsql' ? ['statuses.id', 'created_at'] : DB::raw('Date(created_at)');
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count')
->where('created_at', '>=', now()->subWeek())
->groupBy($gb)
->orderBy('created_at', 'DESC')
@ -86,7 +86,7 @@ class AdminStatsService
$dates = collect($dates)->merge($s);
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count, statuses.*')
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count')
->where('created_at', '>=', now()->subWeeks(2))
->where('created_at', '<=', now()->subWeeks(1))
->groupBy($gb)