fix: refresh btn busts only total cache (fast); fix _pricesFetching button lock

This commit is contained in:
dadaloop82
2026-05-07 20:43:26 +00:00
parent d2e5eea05b
commit 4f98a63414
3 changed files with 18 additions and 23 deletions
+3 -2
View File
@@ -6646,7 +6646,8 @@ function getAllShoppingPrices(PDO $db): void {
$country = trim($input['country'] ?? env('PRICE_COUNTRY', 'Italia'));
$currency = trim($input['currency'] ?? env('PRICE_CURRENCY', 'EUR'));
$lang = trim($input['lang'] ?? 'it');
$forceRefresh = !empty($input['force_refresh']);
$forceRefresh = !empty($input['force_refresh']); // re-fetch AI prices (expensive, rarely used)
$forceTotal = !empty($input['force_total']); // bust only the 5-min total cache (fast)
$updateMonths = (int)env('PRICE_UPDATE_MONTHS', '3');
if (empty($clientItems)) {
@@ -6696,7 +6697,7 @@ function getAllShoppingPrices(PDO $db): void {
$items
)) . $country . $currency);
if (!$forceRefresh && file_exists($totalCachePath)) {
if (!$forceRefresh && !$forceTotal && file_exists($totalCachePath)) {
$tc = json_decode(file_get_contents($totalCachePath), true) ?? [];
if (isset($tc[$totalCacheKey]) && (time() - ($tc[$totalCacheKey]['ts'] ?? 0)) < 300) {
$cached = $tc[$totalCacheKey]['result'];