From d2e5eea05b82cfcf70a3c079b6e78f0510378609 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Thu, 7 May 2026 20:39:44 +0000 Subject: [PATCH] fix: extend PHP timeout for batch price fetch; refresh btn forces recompute --- api/index.php | 7 +++++-- index.html | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/index.php b/api/index.php index a51ca7d..f7a0a44 100644 --- a/api/index.php +++ b/api/index.php @@ -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')); diff --git a/index.html b/index.html index 1196177..c5e4cd0 100644 --- a/index.html +++ b/index.html @@ -635,7 +635,7 @@
💰 Spesa stimata: - +
- +