Skip to content

Commit 72466f1

Browse files
committed
Revert "Merge pull request grokability#17823 from grokability/grokability#17822-fix-n+1-in-topmenu"
This reverts commit 6901dec, reversing changes made to 6b87c90. Signed-off-by: snipe <[email protected]>
1 parent 6901dec commit 72466f1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/Helpers/Helper.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public static function checkLowInventory()
748748
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
749749
$accessories = Accessory::withCount('checkouts as checkouts_count')->whereNotNull('min_amt')->get();
750750
$components = Component::whereNotNull('min_amt')->get();
751-
$asset_models = AssetModel::where('min_amt', '>', 0)->with('assets')->get();
751+
$asset_models = AssetModel::where('min_amt', '>', 0)->get();
752752
$licenses = License::where('min_amt', '>', 0)->get();
753753

754754
$items_array = [];
@@ -811,13 +811,11 @@ public static function checkLowInventory()
811811
}
812812
}
813813

814+
foreach ($asset_models as $asset_model){
814815

815-
816-
817-
foreach ($asset_models as $asset_model) {
818-
819-
$total_owned = $asset_model->assets->count();
820-
$avail = $asset_model->assets->whereNull('assets.assigned_to')->count();
816+
$asset = new Asset();
817+
$total_owned = $asset->where('model_id', '=', $asset_model->id)->count();
818+
$avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count();
821819

822820
if ($avail < ($asset_model->min_amt) + $alert_threshold) {
823821
if ($avail > 0) {

0 commit comments

Comments
 (0)