mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Revert "Cache StockService->GetCurrentStock
result"
This (partly) reverts commit bc5051351a
.
This commit is contained in:
@@ -627,25 +627,19 @@ class StockService extends BaseService
|
|||||||
return $pluginOutput;
|
return $pluginOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $CurrentStockCache = null;
|
|
||||||
|
|
||||||
public function GetCurrentStock()
|
public function GetCurrentStock()
|
||||||
{
|
{
|
||||||
if ($this->CurrentStockCache == null)
|
$sql = 'SELECT * FROM stock_current';
|
||||||
{
|
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_OBJ);
|
||||||
$sql = 'SELECT * FROM stock_current';
|
$relevantProducts = $this->getDatabase()->products()->where('id IN (SELECT product_id FROM (' . $sql . ') x)');
|
||||||
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_OBJ);
|
|
||||||
$relevantProducts = $this->getDatabase()->products()->where('id IN (SELECT product_id FROM (' . $sql . ') x)');
|
|
||||||
foreach ($relevantProducts as $product)
|
|
||||||
{
|
|
||||||
$currentStockMapped[$product->id][0]->product_id = $product->id;
|
|
||||||
$currentStockMapped[$product->id][0]->product = $product;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->CurrentStockCache = array_column($currentStockMapped, 0);
|
foreach ($relevantProducts as $product)
|
||||||
|
{
|
||||||
|
$currentStockMapped[$product->id][0]->product_id = $product->id;
|
||||||
|
$currentStockMapped[$product->id][0]->product = $product;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->CurrentStockCache;
|
return array_column($currentStockMapped, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
|
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
|
||||||
|
Reference in New Issue
Block a user