diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index bbfbbfdd..6fcd1a41 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -105,10 +105,9 @@ class AdminController extends Controller { $col = $request->query('col') ?? 'id'; $dir = $request->query('dir') ?? 'desc'; - $stats = $this->collectUserStats($request); - $users = User::withCount('statuses')->orderBy($col, $dir)->simplePaginate(10); + $users = User::select('id', 'username', 'status')->withCount('statuses')->orderBy($col, $dir)->simplePaginate(10); - return view('admin.users.home', compact('users', 'stats')); + return view('admin.users.home', compact('users')); } public function editUser(Request $request, $id) @@ -158,34 +157,6 @@ class AdminController extends Controller return view('admin.reports.show', compact('report')); } - protected function collectUserStats($request) - { - $total_duration = $request->query('total_duration') ?? '30'; - $new_duration = $request->query('new_duration') ?? '7'; - $stats = []; - $stats['total'] = [ - 'count' => User::where('created_at', '>', Carbon::now()->subDays($total_duration))->count(), - 'points' => 0//User::selectRaw(''.$day.'created_at) day, count(*) as count')->where('created_at','>', Carbon::now()->subDays($total_duration))->groupBy('day')->pluck('count') - ]; - $stats['new'] = [ - 'count' => User::where('created_at', '>', Carbon::now()->subDays($new_duration))->count(), - 'points' => 0//User::selectRaw(''.$day.'created_at) day, count(*) as count')->where('created_at','>', Carbon::now()->subDays($new_duration))->groupBy('day')->pluck('count') - ]; - $stats['active'] = [ - 'count' => Status::groupBy('profile_id')->count() - ]; - $stats['profile'] = [ - 'local' => Profile::whereNull('remote_url')->count(), - 'remote' => Profile::whereNotNull('remote_url')->count() - ]; - $stats['avg'] = [ - 'likes' => floor(Like::average('profile_id')), - 'posts' => floor(Status::avg('profile_id')) - ]; - return $stats; - - } - public function profiles(Request $request) { $this->validate($request, [ diff --git a/resources/views/admin/users/home.blade.php b/resources/views/admin/users/home.blade.php index 1034436a..8bec6c62 100644 --- a/resources/views/admin/users/home.blade.php +++ b/resources/views/admin/users/home.blade.php @@ -13,98 +13,6 @@

Users


-
- {{--
-
-
-
- Total Users - - - -
-
-

{{$stats['total']['count']}}

-
-
-
-
-
-
-
-
-
- New Users - - - -
-
-

{{$stats['new']['count']}}

-
-
-
-
-
--}} -
-
-
-
- Local -
-
-

{{$stats['profile']['local']}}

-
-
-
-
-
-
-
-
- Remote -
-
-

{{$stats['profile']['remote']}}

-
-
-
-
-
-
-
-
- Avg Likes -
-
-

{{$stats['avg']['likes']}}

-
-
-
-
-
-
-
-
- Avg Posts -
-
-

{{$stats['avg']['posts']}}

-
-
-
-
-
@@ -128,27 +36,24 @@ @foreach($users as $user) - @if($user->status == 'deleted') - @continue - @endif
- {{$user->id}} + {{$user->id}} - + - {{$user->username}} + {{$user->username}} @if($user->is_admin) @endif - {{$user->profile->statusCount()}} + {{$user->profile ? $user->profile->statusCount() : 0}} -

+