fix: extend PHP timeout for batch price fetch; refresh btn forces recompute

This commit is contained in:
dadaloop82
2026-05-07 20:39:44 +00:00
parent b412cc0ebe
commit d2e5eea05b
2 changed files with 7 additions and 4 deletions
+5 -2
View File
@@ -6540,8 +6540,8 @@ Rules:
PROMPT;
$payload = ['contents' => [['parts' => [['text' => $prompt]]]]];
// Allow more time for batch (max 45s)
$result = callGeminiWithFallback($apiKey, $payload, 45);
// 55s timeout — generous for large batches (set_time_limit(120) in getAllShoppingPrices)
$result = callGeminiWithFallback($apiKey, $payload, 55);
if ($result['http_code'] !== 200) return [];
@@ -6638,6 +6638,9 @@ function getShoppingPrice(PDO $db): void {
* Returns: { success, prices: { name priceEntry }, total, total_label, from_total_cache }
*/
function getAllShoppingPrices(PDO $db): void {
// This endpoint may call the AI for many items at once — extend timeout.
set_time_limit(120);
$input = json_decode(file_get_contents('php://input'), true) ?? [];
$clientItems = $input['items'] ?? [];
$country = trim($input['country'] ?? env('PRICE_COUNTRY', 'Italia'));
+2 -2
View File
@@ -635,7 +635,7 @@
<div class="shopping-price-total-row">
<span class="price-total-label" data-i18n="shopping.price_total_label">💰 Spesa stimata:</span>
<span class="price-total-value" id="price-total-value"></span>
<button class="btn-price-refresh" id="btn-price-refresh" onclick="fetchAllPrices(false)" title="Aggiorna prezzi">🔄</button>
<button class="btn-price-refresh" id="btn-price-refresh" onclick="fetchAllPrices(true)" title="Aggiorna prezzi">🔄</button>
</div>
<div id="price-loading-bar" style="display:none" class="price-loading-bar">
<div class="price-loading-inner"></div>
@@ -1462,6 +1462,6 @@
</div>
</div>
<script src="assets/js/app.js?v=20260507k"></script>
<script src="assets/js/app.js?v=20260507l"></script>
</body>
</html>