Skip to content

A free open source IT asset/license management system

Re-use total to avoid duplicate count

snipeb1cb9259da2b
diff --git a/app/Http/Controllers/Api/ReportsController.php b/app/Http/Controllers/Api/ReportsController.php
index fbeb78fc8f..8761c9442b 100644
--- a/app/Http/Controllers/Api/ReportsController.php
+++ b/app/Http/Controllers/Api/ReportsController.php
@@ -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();