Autocomplete: period-based dish scoring

Replace flat recency penalty with cycle detection. For each dish with
≥2 appearances in history, compute the median interval between uses and
score by how well weeksSinceLast aligns with that period:
  ratio < 0.5  → 0.10 (too soon)
  ratio ~1.0   → 3.00 (right on schedule, boost)
  ratio > 2.5  → 1.00 (pattern may have changed, neutral)

Expand history window from 4 to 12 weeks so monthly cycles (period=4)
have enough data points to be detected reliably.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-05-27 16:30:22 +02:00
parent 330f21a019
commit e13771fa06
2 changed files with 60 additions and 18 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ final class HomeViewModel: ObservableObject {
let recentPlans = allPlans
.filter { $0.weekStartDate < plan.weekStartDate }
.sorted { $0.weekStartDate > $1.weekStartDate }
.prefix(4)
.prefix(12)
let emptySlots = plan.slots.filter { $0.dishId == nil && !$0.isEatingOut }
let result = AutocompleteEngine.autocomplete(