diff --git a/app/Services/AdminStatsService.php b/app/Services/AdminStatsService.php index 397740434..367157be4 100644 --- a/app/Services/AdminStatsService.php +++ b/app/Services/AdminStatsService.php @@ -27,40 +27,10 @@ class AdminStatsService protected static function recentData() { $day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day('; - return Cache::remember('admin:dashboard:home:data:15min', now()->addMinutes(15), function() use ($day) { + return Cache::remember('admin:dashboard:home:data:v0:15min', now()->addMinutes(15), function() use ($day) { return [ - 'contact' => [ - 'count' => PrettyNumber::convert(Contact::whereNull('read_at')->count()), - 'graph' => Contact::selectRaw('count(*) as count, '.$day.'created_at) as d')->groupBy('d')->whereNull('read_at')->whereBetween('created_at',[now()->subDays(14), now()])->orderBy('d')->pluck('count') - ], - 'failedjobs' => [ - 'count' => PrettyNumber::convert(FailedJob::where('failed_at', '>=', \Carbon\Carbon::now()->subDay())->count()), - 'graph' => FailedJob::selectRaw('count(*) as count, '.$day.'failed_at) as d')->groupBy('d')->whereBetween('failed_at',[now()->subDays(14), now()])->orderBy('d')->pluck('count') - ], - 'reports' => [ - 'count' => PrettyNumber::convert(Report::whereNull('admin_seen')->count()), - 'graph' => Report::selectRaw('count(*) as count, '.$day.'created_at) as d')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('d')->orderBy('d')->pluck('count') - ], - 'statuses' => [ - 'count' => PrettyNumber::convert(Status::whereNull('in_reply_to_id')->whereNull('reblog_of_id')->count()), - 'graph' => Status::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'replies' => [ - 'count' => PrettyNumber::convert(Status::whereNotNull('in_reply_to_id')->count()), - 'graph' => Status::whereNotNull('in_reply_to_id')->selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'shares' => [ - 'count' => PrettyNumber::convert(Status::whereNotNull('reblog_of_id')->count()), - 'graph' => Status::whereNotNull('reblog_of_id')->selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'likes' => [ - 'count' => PrettyNumber::convert(Like::count()), - 'graph' => Like::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'profiles' => [ - 'count' => PrettyNumber::convert(Profile::count()), - 'graph' => Profile::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], + 'contact' => PrettyNumber::convert(Contact::whereNull('read_at')->count()), + 'reports' => PrettyNumber::convert(Report::whereNull('admin_seen')->count()), ]; }); } @@ -68,24 +38,15 @@ class AdminStatsService protected static function additionalData() { $day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day('; - return Cache::remember('admin:dashboard:home:data:24hr', now()->addHours(24), function() use ($day) { + return Cache::remember('admin:dashboard:home:data:v0:24hr', now()->addHours(24), function() use ($day) { return [ - 'users' => [ - 'count' => PrettyNumber::convert(User::count()), - 'graph' => User::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'instances' => [ - 'count' => PrettyNumber::convert(Instance::count()), - 'graph' => Instance::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(28), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'media' => [ - 'count' => PrettyNumber::convert(Media::count()), - 'graph' => Media::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ], - 'storage' => [ - 'count' => Media::sum('size'), - 'graph' => Media::selectRaw('sum(size) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') - ] + 'failedjobs' => PrettyNumber::convert(FailedJob::where('failed_at', '>=', \Carbon\Carbon::now()->subDay())->count()), + 'statuses' => PrettyNumber::convert(Status::whereNull('in_reply_to_id')->whereNull('reblog_of_id')->count()), + 'profiles' => PrettyNumber::convert(Profile::count()), + 'users' => PrettyNumber::convert(User::count()), + 'instances' => PrettyNumber::convert(Instance::count()), + 'media' => PrettyNumber::convert(Media::count()), + 'storage' => Media::sum('size'), ]; }); } diff --git a/resources/views/admin/home.blade.php b/resources/views/admin/home.blade.php index e56d112e8..200986925 100644 --- a/resources/views/admin/home.blade.php +++ b/resources/views/admin/home.blade.php @@ -12,9 +12,8 @@

New Messages

-

{{$data['contact']['count']}}

+

{{$data['contact']}}

-
@@ -22,9 +21,8 @@

Failed Jobs (24h)

-

{{$data['failedjobs']['count']}}

+

{{$data['failedjobs']}}

-
@@ -32,9 +30,8 @@

Reports

-

{{$data['reports']['count']}}

+

{{$data['reports']}}

-
@@ -44,40 +41,8 @@

Statuses

-

{{$data['statuses']['count']}}

+

{{$data['statuses']}}

- -
- - -
-
-
-

Replies

-

{{$data['replies']['count']}}

-
- -
-
-
-
-
-

Shares (Reblogs)

-

{{$data['shares']['count']}}

-
- -
-
- - -
-
-
-
-

Likes

-

{{$data['likes']['count']}}

-
-
@@ -85,9 +50,8 @@

Profiles

-

{{$data['profiles']['count']}}

+

{{$data['profiles']}}

-
@@ -95,9 +59,8 @@

Users

-

{{$data['users']['count']}}

+

{{$data['users']}}

-
@@ -107,9 +70,8 @@

Remote Instances

-

{{$data['instances']['count']}}

+

{{$data['instances']}}

-
@@ -117,25 +79,22 @@

Photos Uploaded

-

{{$data['media']['count']}}

+

{{$data['media']}}

-

Storage Used

-

{{$data['storage']['count']}} bytes

+

{{$data['storage']}} bytes

-
@endsection @push('scripts') - @endpush \ No newline at end of file