From f2290cf77f9254a2325f9282899122dfb5ec8882 Mon Sep 17 00:00:00 2001 From: elpatron Date: Tue, 18 Mar 2025 15:33:01 +0100 Subject: [PATCH] Version 1.2.6: Verbesserte Suchfunktion und Highlighting - app.py aktualisiert --- app.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index a414152..b096550 100644 --- a/app.py +++ b/app.py @@ -38,7 +38,7 @@ def init_db(): conn = sqlite3.connect(DB_FILE) c = conn.cursor() - # Erstelle die Tabelle mit Indizes + # Erstelle die Tabelle c.execute(''' CREATE TABLE IF NOT EXISTS customers ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -124,6 +124,19 @@ def import_csv(): def search_customers(search_params): """Sucht nach Kunden basierend auf den Suchparametern.""" + # Prüfe, ob alle Suchfelder leer sind + if not any([ + search_params.get('q'), + search_params.get('name'), + search_params.get('ort'), + search_params.get('nummer'), + search_params.get('plz'), + search_params.get('telefon'), + search_params.get('email'), + search_params.get('fachrichtung') + ]): + return [] + conn = sqlite3.connect(DB_FILE) c = conn.cursor() @@ -154,6 +167,10 @@ def search_customers(search_params): if search_params.get('plz'): query += " AND plz LIKE ?" params.append(f"%{search_params['plz']}%") + + if search_params.get('fachrichtung'): + query += " AND fachrichtung LIKE ?" + params.append(f"%{search_params['fachrichtung']}%") # Führe die Abfrage aus c.execute(query, params)