fix: extend PHP timeout for batch price fetch; refresh btn forces recompute
This commit is contained in:
+5
-2
@@ -6540,8 +6540,8 @@ Rules:
|
|||||||
PROMPT;
|
PROMPT;
|
||||||
|
|
||||||
$payload = ['contents' => [['parts' => [['text' => $prompt]]]]];
|
$payload = ['contents' => [['parts' => [['text' => $prompt]]]]];
|
||||||
// Allow more time for batch (max 45s)
|
// 55s timeout — generous for large batches (set_time_limit(120) in getAllShoppingPrices)
|
||||||
$result = callGeminiWithFallback($apiKey, $payload, 45);
|
$result = callGeminiWithFallback($apiKey, $payload, 55);
|
||||||
|
|
||||||
if ($result['http_code'] !== 200) return [];
|
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 }
|
* Returns: { success, prices: { name → priceEntry }, total, total_label, from_total_cache }
|
||||||
*/
|
*/
|
||||||
function getAllShoppingPrices(PDO $db): void {
|
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) ?? [];
|
$input = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
$clientItems = $input['items'] ?? [];
|
$clientItems = $input['items'] ?? [];
|
||||||
$country = trim($input['country'] ?? env('PRICE_COUNTRY', 'Italia'));
|
$country = trim($input['country'] ?? env('PRICE_COUNTRY', 'Italia'));
|
||||||
|
|||||||
+2
-2
@@ -635,7 +635,7 @@
|
|||||||
<div class="shopping-price-total-row">
|
<div class="shopping-price-total-row">
|
||||||
<span class="price-total-label" data-i18n="shopping.price_total_label">💰 Spesa stimata:</span>
|
<span class="price-total-label" data-i18n="shopping.price_total_label">💰 Spesa stimata:</span>
|
||||||
<span class="price-total-value" id="price-total-value">–</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>
|
||||||
<div id="price-loading-bar" style="display:none" class="price-loading-bar">
|
<div id="price-loading-bar" style="display:none" class="price-loading-bar">
|
||||||
<div class="price-loading-inner"></div>
|
<div class="price-loading-inner"></div>
|
||||||
@@ -1462,6 +1462,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="assets/js/app.js?v=20260507k"></script>
|
<script src="assets/js/app.js?v=20260507l"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user