Skip to content

Commit

Permalink
Scan: Don't lookup from ldap (#256)
Browse files Browse the repository at this point in the history
Lookup from db instead.

Removes the lag when scanning a barcode.
  • Loading branch information
soerface authored Nov 5, 2024
1 parent d11b177 commit 4506f6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions drinks_touch/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions drinks_touch/screens/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions drinks_touch/screens/wait_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4506f6f

Please sign in to comment.