|
@@ -45,50 +45,51 @@ class AdminController extends Controller
|
|
public function home()
|
|
public function home()
|
|
{
|
|
{
|
|
$data = Cache::remember('admin:dashboard:home:data', 15, function() {
|
|
$data = Cache::remember('admin:dashboard:home:data', 15, function() {
|
|
|
|
+ $day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day(';
|
|
return [
|
|
return [
|
|
'failedjobs' => [
|
|
'failedjobs' => [
|
|
'count' => PrettyNumber::convert(FailedJob::where('failed_at', '>=', \Carbon\Carbon::now()->subDay())->count()),
|
|
'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(24), now()])->orderBy('d')->pluck('count')
|
|
|
|
|
|
+ 'graph' => FailedJob::selectRaw('count(*) as count, '.$day.'failed_at) as d')->groupBy('d')->whereBetween('failed_at',[now()->subDays(24), now()])->orderBy('d')->pluck('count')
|
|
],
|
|
],
|
|
'reports' => [
|
|
'reports' => [
|
|
'count' => PrettyNumber::convert(Report::whereNull('admin_seen')->count()),
|
|
'count' => PrettyNumber::convert(Report::whereNull('admin_seen')->count()),
|
|
- 'graph' => Report::selectRaw('count(*) as count, day(created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count')
|
|
|
|
|
|
+ 'graph' => Report::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count')
|
|
],
|
|
],
|
|
'statuses' => [
|
|
'statuses' => [
|
|
'count' => PrettyNumber::convert(Status::whereNull('in_reply_to_id')->whereNull('reblog_of_id')->count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'replies' => [
|
|
'count' => PrettyNumber::convert(Status::whereNotNull('in_reply_to_id')->count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'shares' => [
|
|
'count' => PrettyNumber::convert(Status::whereNotNull('reblog_of_id')->count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'likes' => [
|
|
'count' => PrettyNumber::convert(Like::count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'profiles' => [
|
|
'count' => PrettyNumber::convert(Profile::count()),
|
|
'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')
|
|
|
|
|
|
+ 'graph' => Profile::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count')
|
|
],
|
|
],
|
|
'users' => [
|
|
'users' => [
|
|
'count' => PrettyNumber::convert(User::count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'instances' => [
|
|
'count' => PrettyNumber::convert(Instance::count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'media' => [
|
|
'count' => PrettyNumber::convert(Media::count()),
|
|
'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')
|
|
|
|
|
|
+ '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' => [
|
|
'storage' => [
|
|
'count' => Media::sum('size'),
|
|
'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')
|
|
|
|
|
|
+ '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')
|
|
]
|
|
]
|
|
];
|
|
];
|
|
});
|
|
});
|
|
@@ -159,11 +160,11 @@ class AdminController extends Controller
|
|
$stats = [];
|
|
$stats = [];
|
|
$stats['total'] = [
|
|
$stats['total'] = [
|
|
'count' => User::where('created_at', '>', Carbon::now()->subDays($total_duration))->count(),
|
|
'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')
|
|
|
|
|
|
+ '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'] = [
|
|
$stats['new'] = [
|
|
'count' => User::where('created_at', '>', Carbon::now()->subDays($new_duration))->count(),
|
|
'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')
|
|
|
|
|
|
+ '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'] = [
|
|
$stats['active'] = [
|
|
'count' => Status::groupBy('profile_id')->count()
|
|
'count' => Status::groupBy('profile_id')->count()
|