Improve Performance (#927)

* Stock-Overview: Reduce amount of database queries and FindObjectInArray()-calls

* Speed-up stock_current by improving products_resolved and creating indices.

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
fipwmaqzufheoxq92ebc
2020-08-18 19:23:37 +02:00
committed by GitHub
parent 7510c677f1
commit 42dc55625a
5 changed files with 134 additions and 37 deletions

View File

@@ -14,7 +14,16 @@ class StockService extends BaseService
const TRANSACTION_TYPE_PRODUCT_OPENED = 'product-opened';
const TRANSACTION_TYPE_SELF_PRODUCTION = 'self-production';
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
public function GetCurrentStockOverview()
{
if (!GROCY_FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT) {
return $this->getDatabase()->uihelper_stock_current_overview();
} else {
return $this->getDatabase()->uihelper_stock_current_overview_including_opened();
}
}
public function GetCurrentStock($includeNotInStockButMissingProducts = false)
{
$sql = 'SELECT * FROM stock_current';
if ($includeNotInStockButMissingProducts)