chore: auto-merge develop → main

Triggered by: cb39b63 fix: drastically reduce false-positive consumption anomaly banners
This commit is contained in:
github-actions[bot]
2026-05-11 17:33:31 +00:00
2 changed files with 15 additions and 3 deletions
+13 -1
View File
@@ -2166,9 +2166,21 @@ function getConsumptionPredictions(PDO $db): void {
// Flag if deviation > 30% and absolute diff > meaningful threshold
$deviation = abs($actualQty - $expectedQty);
$threshold = max($dailyRate * 3, 0.5); // at least 3 days worth or 0.5 units
// If expected = 0 and actual > 0, the model simply thinks the product
// should have been used up by now. This is NOT an anomaly — the user
// either restocked (not yet tracked) or consumed less than usual.
// Only flag "less" direction when expected = 0 (actual ran out faster).
if ($expectedQty <= 0 && $actualQty >= 0) continue;
$pctDev = $expectedQty > 0 ? ($deviation / $expectedQty) : ($actualQty > 0 ? 1 : 0);
if ($pctDev > 0.30 && $deviation > $threshold) {
// "more than expected" is almost always a restock the model doesn't know about yet.
// Only flag it at very high deviation (>400%) to catch truly impossible values.
// "less than expected" is more actionable: user may have consumed without registering.
$flagThreshold = ($actualQty > $expectedQty) ? 4.0 : 0.30;
if ($pctDev > $flagThreshold && $deviation > $threshold) {
$unit = $item['unit'];
// Format expected/actual in human units
if ($unit === 'conf' && $item['default_quantity'] > 0 && $item['package_unit']) {
+2 -2
View File
@@ -11,7 +11,7 @@
<title>EverShelf</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" href="assets/img/logo/logo_icon.png">
<link rel="stylesheet" href="assets/css/style.css?v=20260511h">
<link rel="stylesheet" href="assets/css/style.css?v=20260511i">
<!-- QuaggaJS for barcode scanning -->
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2@1.8.4/dist/quagga.min.js"></script>
<!-- @xenova/transformers: ES-module bootstrap that exposes a lazy category-classifier as window._categoryPipelinePromise -->
@@ -1469,6 +1469,6 @@
</div>
</div>
<script src="assets/js/app.js?v=20260511h"></script>
<script src="assets/js/app.js?v=20260511i"></script>
</body>
</html>