FEATURE #2389 @2h: group http request by url
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php namespace Modules\Profiler\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Admin\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Modules\Profiler\Entities\HttpLog;
|
||||
|
||||
@@ -9,21 +10,36 @@ class ProfilerController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$filters = [];
|
||||
$httpLog = HttpLog::orderBy('created_at', 'DESC')
|
||||
->with('queries');
|
||||
$pastDays = Input::get('pastDays', session('profilerPastDays', 0));
|
||||
$httpLog = HttpLog::query();
|
||||
|
||||
if (is_numeric($pastDays) && $pastDays >= 0) {
|
||||
$httpLog = $httpLog->where('created_at', '>=', Carbon::today()
|
||||
->subDays($pastDays));
|
||||
}
|
||||
|
||||
session(['profilerPastDays' => $pastDays]);
|
||||
|
||||
if (Input::get('method')) {
|
||||
$filters[] = 'method';
|
||||
$httpLog = $httpLog->where('method', Input::get('method'));
|
||||
}
|
||||
|
||||
$displayGrouped = false;
|
||||
|
||||
if (Input::get('url')) {
|
||||
$filters[] = 'url';
|
||||
$httpLog = $httpLog->where('url', Input::get('url'));
|
||||
$httpLog = $httpLog->where('url', Input::get('url'))
|
||||
->with('queries');
|
||||
} else {
|
||||
$displayGrouped = true;
|
||||
$httpLog = $httpLog->groupBy('url', 'method')
|
||||
->select(\DB::raw('*'), \DB::raw('COUNT(url) as total'), \DB::raw('AVG(time) as time_avg'))
|
||||
->orderBy('total', 'DESC');
|
||||
}
|
||||
|
||||
$httpLog = $httpLog->paginate(25);
|
||||
|
||||
return view('profiler::index', compact('httpLog'));
|
||||
$filter = Input::all();
|
||||
return view('profiler::index', compact('httpLog', 'displayGrouped', 'filter', 'pastDays'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user