mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Performance optimizations
This commit is contained in:
parent
76e4a1578c
commit
b2d7003335
@ -338,7 +338,6 @@ class StockController extends BaseController
|
|||||||
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
|
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
|
||||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
|
||||||
'missingProducts' => $this->getStockService()->GetMissingProducts(),
|
'missingProducts' => $this->getStockService()->GetMissingProducts(),
|
||||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
|
|
||||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
|
||||||
'selectedShoppingListId' => $listId,
|
'selectedShoppingListId' => $listId,
|
||||||
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
|
||||||
|
@ -8,7 +8,10 @@ SELECT
|
|||||||
p.name AS product_name,
|
p.name AS product_name,
|
||||||
plp.price * IFNULL(qucr.factor, 1.0) AS last_price_unit,
|
plp.price * IFNULL(qucr.factor, 1.0) AS last_price_unit,
|
||||||
plp.price * IFNULL(qucr.factor, 1.0) * sl.amount AS last_price_total,
|
plp.price * IFNULL(qucr.factor, 1.0) * sl.amount AS last_price_total,
|
||||||
st.name AS default_shopping_location_name
|
st.name AS default_shopping_location_name,
|
||||||
|
qu.name AS qu_name,
|
||||||
|
qu.name_plural AS qu_name_plural,
|
||||||
|
pg.name AS product_group_name
|
||||||
FROM shopping_list sl
|
FROM shopping_list sl
|
||||||
LEFT JOIN products p
|
LEFT JOIN products p
|
||||||
ON sl.product_id = p.id
|
ON sl.product_id = p.id
|
||||||
@ -19,4 +22,8 @@ LEFT JOIN quantity_unit_conversions_resolved qucr
|
|||||||
LEFT JOIN products_last_purchased plp
|
LEFT JOIN products_last_purchased plp
|
||||||
ON sl.product_id = plp.product_id
|
ON sl.product_id = plp.product_id
|
||||||
LEFT JOIN shopping_locations st
|
LEFT JOIN shopping_locations st
|
||||||
ON p.shopping_location_id = st.id;
|
ON p.shopping_location_id = st.id
|
||||||
|
LEFT JOIN quantity_units qu
|
||||||
|
ON sl.qu_id = qu.id
|
||||||
|
LEFT JOIN product_groups pg
|
||||||
|
ON p.product_group_id = pg.id;
|
||||||
|
@ -109,3 +109,13 @@ BEGIN
|
|||||||
DELETE FROM battery_charge_cycles
|
DELETE FROM battery_charge_cycles
|
||||||
WHERE battery_id = OLD.id;
|
WHERE battery_id = OLD.id;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
CREATE INDEX ix_chores_performance1 ON chores (
|
||||||
|
id,
|
||||||
|
active
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX ix_batteries_performance1 ON batteries (
|
||||||
|
id,
|
||||||
|
active
|
||||||
|
);
|
||||||
|
@ -206,13 +206,13 @@
|
|||||||
</a>
|
</a>
|
||||||
<a class="btn btn-sm btn-primary @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif @if(empty($listItem->product_id)) disabled @else shopping-list-stock-add-workflow-list-item-button @endif"
|
<a class="btn btn-sm btn-primary @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif @if(empty($listItem->product_id)) disabled @else shopping-list-stock-add-workflow-list-item-button @endif"
|
||||||
href="{{ $U('/purchase?embedded&flow=shoppinglistitemtostock&product=') }}{{ $listItem->product_id }}&amount={{ $listItem->amount }}&listitemid={{ $listItem->id }}&quId={{ $listItem->qu_id }}"
|
href="{{ $U('/purchase?embedded&flow=shoppinglistitemtostock&product=') }}{{ $listItem->product_id }}&amount={{ $listItem->amount }}&listitemid={{ $listItem->id }}&quId={{ $listItem->qu_id }}"
|
||||||
@if(!empty($listItem->product_id)) data-toggle="tooltip" title="{{ $__t('Add %1$s of %2$s to stock', $listItem->amount . ' ' . $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural), FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name, $listItem->amount) }}" @endif>
|
@if(!empty($listItem->product_id)) data-toggle="tooltip" title="{{ $__t('Add %1$s of %2$s to stock', $listItem->amount . ' ' . $__n($listItem->amount, $listItem->qu_name, $listItem->qu_name_plural), $listItem->product_name, $listItem->amount) }}" @endif>
|
||||||
<i class="fas fa-box"></i>
|
<i class="fas fa-box"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="product-name-cell cursor-link"
|
<td class="product-name-cell cursor-link"
|
||||||
data-product-id="{{ $listItem->product_id }}">
|
data-product-id="{{ $listItem->product_id }}">
|
||||||
@if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
@if(!empty($listItem->product_id)) {{ $listItem->product_name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
||||||
</td>
|
</td>
|
||||||
@if(!empty($listItem->product_id))
|
@if(!empty($listItem->product_id))
|
||||||
@php
|
@php
|
||||||
@ -228,10 +228,10 @@
|
|||||||
@endphp
|
@endphp
|
||||||
@endif
|
@endif
|
||||||
<td data-order={{ $listItem->amount }}>
|
<td data-order={{ $listItem->amount }}>
|
||||||
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif
|
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, $listItem->qu_name, $listItem->qu_name_plural) }}@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else <span class="font-italic font-weight-light">{{ $__t('Ungrouped') }}</span> @endif
|
@if(!empty($listItem->product_group_name)) {{ $listItem->product_group_name }} @else <span class="font-italic font-weight-light">{{ $__t('Ungrouped') }}</span> @endif
|
||||||
</td>
|
</td>
|
||||||
<td id="shoppinglistitem-{{ $listItem->id }}-status-info"
|
<td id="shoppinglistitem-{{ $listItem->id }}-status-info"
|
||||||
class="d-none">
|
class="d-none">
|
||||||
@ -349,13 +349,13 @@
|
|||||||
@foreach($listItems as $listItem)
|
@foreach($listItems as $listItem)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
@if(!empty($listItem->product_id)) {{ $listItem->product_name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif
|
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, $listItem->qu_name, $listItem->qu_name_plural) }}@endif
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else <span class="font-italic font-weight-light">{{ $__t('Ungrouped') }}</span> @endif
|
@if(!empty($listItem->product_group_name)) {{ $listItem->product_group_name }} @else <span class="font-italic font-weight-light">{{ $__t('Ungrouped') }}</span> @endif
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@include('components.userfields_tbody', array(
|
@include('components.userfields_tbody', array(
|
||||||
@ -372,8 +372,8 @@
|
|||||||
<div class="w-75 print-layout-type-list d-none">
|
<div class="w-75 print-layout-type-list d-none">
|
||||||
@foreach($listItems as $listItem)
|
@foreach($listItems as $listItem)
|
||||||
<div class="py-0">
|
<div class="py-0">
|
||||||
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $listItem->qu_id)->name_plural) }}@endif
|
<span class="locale-number locale-number-quantity-amount">{{ $listItem->amount }}</span> @if(!empty($listItem->product_id)){{ $__n($listItem->amount, $listItem->qu_name, $listItem->qu_name_plural) }}@endif
|
||||||
@if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
@if(!empty($listItem->product_id)) {{ $listItem->product_name }}<br>@endif<em>{!! nl2br($listItem->note) !!}</em>
|
||||||
</div><br>
|
</div><br>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user