mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Fixed GetCurrentStock
caching
This commit is contained in:
@@ -620,9 +620,9 @@ class StockService extends BaseService
|
||||
}
|
||||
|
||||
private static $CurrentStockCache = null;
|
||||
public function GetCurrentStock()
|
||||
public function GetCurrentStock(bool $useCache = false)
|
||||
{
|
||||
if (self::$CurrentStockCache == null)
|
||||
if (!$useCache || self::$CurrentStockCache == null)
|
||||
{
|
||||
$sql = 'SELECT * FROM stock_current';
|
||||
$currentStockMapped = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_GROUP | \PDO::FETCH_OBJ);
|
||||
@@ -665,7 +665,7 @@ class StockService extends BaseService
|
||||
|
||||
public function GetDueProducts(int $days = 5, bool $excludeOverdue = false)
|
||||
{
|
||||
$currentStock = $this->GetCurrentStock();
|
||||
$currentStock = $this->GetCurrentStock(true);
|
||||
$currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime("+$days days")), '<');
|
||||
|
||||
if ($excludeOverdue)
|
||||
@@ -678,7 +678,7 @@ class StockService extends BaseService
|
||||
|
||||
public function GetExpiredProducts()
|
||||
{
|
||||
$currentStock = $this->GetCurrentStock();
|
||||
$currentStock = $this->GetCurrentStock(true);
|
||||
$currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime('-1 days')), '<');
|
||||
$currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'due_type', 2);
|
||||
|
||||
|
Reference in New Issue
Block a user