1
0
Fork 0
forked from mirror/pixelfed

Update AdminController

This commit is contained in:
Daniel Supernault 2019-06-18 19:15:12 -06:00
parent e33dd43dc2
commit 4a62aeee19
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\{
Contact,
FailedJob,
Hashtag,
Instance,
@ -47,6 +48,10 @@ class AdminController extends Controller
$data = Cache::remember('admin:dashboard:home:data', now()->addMinutes(15), function() {
$day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day(';
return [
'contact' => [
'count' => PrettyNumber::convert(Contact::whereNull('read_at')->count()),
'graph' => Contact::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereNull('read_at')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->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(24), now()])->orderBy('d')->pluck('count')
@ -248,4 +253,9 @@ class AdminController extends Controller
return view('admin.hashtags.home', compact('hashtags'));
}
public function messagesHome(Request $request)
{
$messages = Contact::orderByDesc('id')->paginate(10);
return view('admin.messages.home', compact('messages'));
}
}