feat: fuzzy matching Picnic ↔ Leclerc + page /matches dans le dashboard
Nouvelle table product_matches (status: pending/validated/rejected).
Matching via RapidFuzz token_sort_ratio, seuil configurable (défaut 85%).
Workflow :
1. python -m tickettracker.cli match [--threshold 85]
→ calcule et stocke les paires candidates
2. http://localhost:8000/matches
→ l'utilisateur valide ou rejette chaque paire
3. La comparaison de prix enrichie avec les paires validées
Nouvelles dépendances : rapidfuzz, watchdog (requirements.txt).
10 tests ajoutés (test_matcher.py), tous passent.
Suite complète : 129 passent, 1 xfail, 0 échec.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,23 @@ CREATE INDEX IF NOT EXISTS idx_items_name_normalized
|
||||
ON items (name_normalized);
|
||||
"""
|
||||
|
||||
_SQL_CREATE_PRODUCT_MATCHES = """
|
||||
CREATE TABLE IF NOT EXISTS product_matches (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name_picnic TEXT NOT NULL,
|
||||
name_leclerc TEXT NOT NULL,
|
||||
score REAL NOT NULL, -- score RapidFuzz 0-100
|
||||
status TEXT NOT NULL DEFAULT 'pending', -- 'pending'|'validated'|'rejected'
|
||||
created_at TEXT NOT NULL,
|
||||
UNIQUE(name_picnic, name_leclerc)
|
||||
);
|
||||
"""
|
||||
|
||||
_SQL_CREATE_PRODUCT_MATCHES_IDX = """
|
||||
CREATE INDEX IF NOT EXISTS idx_product_matches_status
|
||||
ON product_matches (status);
|
||||
"""
|
||||
|
||||
_SQL_CREATE_PRICE_HISTORY = """
|
||||
CREATE VIEW IF NOT EXISTS price_history AS
|
||||
SELECT
|
||||
@@ -125,3 +142,5 @@ def init_db(db_path: str | Path = DEFAULT_DB_PATH) -> None:
|
||||
conn.execute(_SQL_CREATE_ITEMS_IDX)
|
||||
conn.execute(_SQL_CREATE_ITEMS_NORM_IDX)
|
||||
conn.execute(_SQL_CREATE_PRICE_HISTORY)
|
||||
conn.execute(_SQL_CREATE_PRODUCT_MATCHES)
|
||||
conn.execute(_SQL_CREATE_PRODUCT_MATCHES_IDX)
|
||||
|
||||
Reference in New Issue
Block a user