Merge pull request #2770 from pixelfed/staging

Update AdminStatsService, fix postgres bug
This commit is contained in:
daniel 2021-05-25 01:37:13 -06:00 committed by GitHub
commit bfe6969dae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -94,6 +94,7 @@
- Updated StatusTransformer, fix missing tags attribute. ([dac326e9](https://github.com/pixelfed/pixelfed/commit/dac326e9))
- Updated ComposeController, bail on empty attachments. ([061b145b](https://github.com/pixelfed/pixelfed/commit/061b145b))
- Updated landing and about page. ([92dc7af6](https://github.com/pixelfed/pixelfed/commit/92dc7af6))
- Updated AdminStatsService, fix postgres bug. ([af719135](https://github.com/pixelfed/pixelfed/commit/af719135))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)

View file

@ -67,10 +67,11 @@ class AdminStatsService
protected static function postsGraph()
{
$ttl = now()->addHours(12);
return Cache::remember('admin:dashboard:home:data-postsGraph:v0:24hr', $ttl, function() {
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.*')
->where('created_at', '>=', now()->subWeek())
->groupBy(DB::raw('Date(created_at)'))
->groupBy($gb)
->orderBy('created_at', 'DESC')
->pluck('count', 'date');
@ -88,7 +89,7 @@ class AdminStatsService
$s = Status::selectRaw('Date(created_at) as date, count(statuses.id) as count, statuses.*')
->where('created_at', '>=', now()->subWeeks(2))
->where('created_at', '<=', now()->subWeeks(1))
->groupBy(DB::raw('Date(created_at)'))
->groupBy($gb)
->orderBy('created_at', 'DESC')
->pluck('count', 'date');