From 4506f6ff847bbac2d396989db4addf82279de6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Wegener?= Date: Tue, 5 Nov 2024 20:08:08 +0100 Subject: [PATCH] Scan: Don't lookup from ldap (#256) Lookup from db instead. Removes the lag when scanning a barcode. --- drinks_touch/screens/main.py | 7 +++---- drinks_touch/screens/profile.py | 6 +++--- drinks_touch/screens/wait_scan.py | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drinks_touch/screens/main.py b/drinks_touch/screens/main.py index 09970f30..0da2ad3f 100644 --- a/drinks_touch/screens/main.py +++ b/drinks_touch/screens/main.py @@ -8,7 +8,6 @@ from elements.image import Image from elements.label import Label from elements.progress import Progress -from users.users import Users from .names import NamesScreen from .screen import Screen @@ -88,9 +87,9 @@ def on_barcode(self, barcode): if not barcode: return - user = Users.get_by_id_card(barcode) - if user: - ScreenManager.get_instance().set_active(ProfileScreen(self.screen, user)) + account = Account.query.filter(Account.id_card == barcode).first() + if account: + ScreenManager.get_instance().set_active(ProfileScreen(self.screen, account)) @staticmethod def __get_pos(i): diff --git a/drinks_touch/screens/profile.py b/drinks_touch/screens/profile.py index 3596d369..7e2b0dce 100644 --- a/drinks_touch/screens/profile.py +++ b/drinks_touch/screens/profile.py @@ -269,9 +269,9 @@ def on_barcode(self, barcode): return self.processing.text = f"Gescannt: {barcode}" self.processing.is_visible = True - user = Users.get_by_id_card(barcode) - if user: - ScreenManager.get_instance().set_active(ProfileScreen(self.screen, user)) + account = Account.query.filter(Account.id_card == barcode).first() + if account: + ScreenManager.get_instance().set_active(ProfileScreen(self.screen, account)) self.processing.is_visible = False return drink = get_by_ean(barcode) diff --git a/drinks_touch/screens/wait_scan.py b/drinks_touch/screens/wait_scan.py index d86bd185..d48fe29e 100644 --- a/drinks_touch/screens/wait_scan.py +++ b/drinks_touch/screens/wait_scan.py @@ -3,6 +3,7 @@ import logging import config +from database.models import Account from database.models.scan_event import ScanEvent from database.storage import get_session from drinks.drinks import get_by_ean @@ -13,7 +14,6 @@ from screens.new_id_screen import NewIDScreen from screens.profile import ProfileScreen from tasks import CheckForUpdatesTask -from users.users import Users from .git.main_screen import GitMainScreen from .main import MainScreen from .screen import Screen @@ -209,9 +209,9 @@ def on_barcode(self, barcode): return self.processing.text = f"Gescannt: {barcode}" self.processing.is_visible = True - user = Users.get_by_id_card(barcode) - if user: - ScreenManager.get_instance().set_active(ProfileScreen(self.screen, user)) + account = Account.query.filter(Account.id_card == barcode).first() + if account: + ScreenManager.get_instance().set_active(ProfileScreen(self.screen, account)) self.processing.is_visible = False return drink = get_by_ean(barcode)