From ccc2f8907d5fc26bc0af90e648ad33fffb7165e8 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Wed, 20 May 2026 13:41:04 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20depleted=20items=20urgency=20=E2=80=94?= =?UTF-8?q?=20use=20buyCount/useCount=20from=20internal=20history=20to=20a?= =?UTF-8?q?ssign=20medium/low?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/api/index.php b/api/index.php index 3e7a394..bbea0b6 100644 --- a/api/index.php +++ b/api/index.php @@ -7658,11 +7658,20 @@ function smartShopping(PDO $db): void { $reasons[] = 'Esaurito'; $score += 30; } else { - // Product is depleted. Even without a proven usage pattern, always - // show at minimum 'low' so the user can restock it. - $urgency = 'low'; + // Product is depleted. Use internal history variables to set urgency: + // bought ≥2 times → medium (proven restock item), once → low (might want it), + // never bought (manually added) → low. $reasons[] = 'Esaurito'; - $score += 15; + if ($buyCount >= 2) { + $urgency = 'medium'; + $score += 45; + } elseif ($buyCount >= 1 || $useCount >= 2) { + $urgency = 'low'; + $score += 25; + } else { + $urgency = 'low'; + $score += 10; + } } }