mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-31 23:51:19 -08:00
Merge pull request #14777 from snipe/fixes/reportscontroller_optimizations
Reports controller query optimizations
This commit is contained in:
commit
fceba13b03
|
@ -78,13 +78,14 @@ class ReportsController extends Controller
|
|||
];
|
||||
|
||||
|
||||
$total = $actionlogs->count();
|
||||
// Make sure the offset and limit are actually integers and do not exceed system limits
|
||||
$offset = ($request->input('offset') > $actionlogs->count()) ? $actionlogs->count() : app('api_offset_value');
|
||||
$offset = ($request->input('offset') > $total) ? $total : app('api_offset_value');
|
||||
$limit = app('api_limit_value');
|
||||
|
||||
$sort = in_array($request->input('sort'), $allowed_columns) ? e($request->input('sort')) : 'created_at';
|
||||
$order = ($request->input('order') == 'asc') ? 'asc' : 'desc';
|
||||
$total = $actionlogs->count();
|
||||
|
||||
|
||||
$actionlogs = $actionlogs->orderBy($sort, $order)->skip($offset)->take($limit)->get();
|
||||
|
||||
|
|
|
@ -48,7 +48,12 @@ class ActionlogsTransformer
|
|||
public function transformActionlog (Actionlog $actionlog, $settings = null)
|
||||
{
|
||||
$icon = $actionlog->present()->icon();
|
||||
$custom_fields = CustomField::all();
|
||||
|
||||
static $custom_fields = false;
|
||||
|
||||
if ($custom_fields === false) {
|
||||
$custom_fields = CustomField::all();
|
||||
}
|
||||
|
||||
if ($actionlog->filename!='') {
|
||||
$icon = Helper::filetype_icon($actionlog->filename);
|
||||
|
@ -216,13 +221,30 @@ class ActionlogsTransformer
|
|||
*/
|
||||
|
||||
public function changedInfo(array $clean_meta)
|
||||
{ $location = Location::withTrashed()->get();
|
||||
$supplier = Supplier::withTrashed()->get();
|
||||
$model = AssetModel::withTrashed()->get();
|
||||
$status = Statuslabel::withTrashed()->get();
|
||||
$company = Company::get();
|
||||
{
|
||||
static $location = false;
|
||||
static $supplier = false;
|
||||
static $model = false;
|
||||
static $status = false;
|
||||
static $company = false;
|
||||
|
||||
|
||||
if ($location === false) {
|
||||
$location = Location::select('id', 'name')->withTrashed()->get();
|
||||
}
|
||||
if ($supplier === false) {
|
||||
$supplier = Supplier::select('id', 'name')->withTrashed()->get();
|
||||
}
|
||||
if ($model === false) {
|
||||
$model = AssetModel::select('id', 'name')->withTrashed()->get();
|
||||
}
|
||||
if ($status === false) {
|
||||
$status = Statuslabel::select('id', 'name')->withTrashed()->get();
|
||||
}
|
||||
if ($company === false) {
|
||||
$company = Company::select('id', 'name')->get();
|
||||
}
|
||||
|
||||
if(array_key_exists('rtd_location_id',$clean_meta)) {
|
||||
|
||||
$oldRtd = $location->find($clean_meta['rtd_location_id']['old']);
|
||||
|
|
|
@ -60,6 +60,12 @@ class Asset extends Depreciable
|
|||
*/
|
||||
protected $table = 'assets';
|
||||
|
||||
/**
|
||||
* Leaving this commented out, since we need to test further, but this would eager load the model relationship every single
|
||||
* time the asset model is loaded.
|
||||
*/
|
||||
// protected $with = ['model'];
|
||||
|
||||
/**
|
||||
* Whether the model should inject it's identifier to the unique
|
||||
* validation rules before attempting validation. If this property
|
||||
|
|
Loading…
Reference in a new issue