mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Optimized performance of CurrentVolatileStock
This commit is contained in:
@@ -619,7 +619,10 @@ class StockService extends BaseService
|
|||||||
return $pluginOutput;
|
return $pluginOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static $CurrentStockCache = null;
|
||||||
public function GetCurrentStock()
|
public function GetCurrentStock()
|
||||||
|
{
|
||||||
|
if (self::$CurrentStockCache == null)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT * FROM stock_current';
|
$sql = 'SELECT * FROM stock_current';
|
||||||
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_OBJ);
|
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_OBJ);
|
||||||
@@ -631,7 +634,10 @@ class StockService extends BaseService
|
|||||||
$currentStockMapped[$product->id][0]->product = $product;
|
$currentStockMapped[$product->id][0]->product = $product;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_column($currentStockMapped, 0);
|
self::$CurrentStockCache = array_column($currentStockMapped, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$CurrentStockCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
|
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
|
||||||
|
Reference in New Issue
Block a user