bugfix, free_drink_list_history wenn kein dienst

Sollte der user, der diese liste abruft keinen dienst haben, wird nur die history der letzten halben stunde abgerufen
This commit is contained in:
Tim Gröger 2020-08-20 20:17:35 +02:00
parent e5d2de4d35
commit 7ac3813782
1 changed files with 5 additions and 1 deletions

View File

@ -97,7 +97,11 @@ class Base:
cursor = self.db.connection.cursor() cursor = self.db.connection.cursor()
now = datetime.now() now = datetime.now()
worker = self.getWorker(user, now) worker = self.getWorker(user, now)
cursor.execute(f'select * from free_drink_list_history where timestamp>="{worker["startdatetime"]}" and (user_id={user.id} or free_drink_type_id=3)') if worker:
timestamp = worker["startdatetime"]
else:
timestamp = datetime.now() - timedelta(minutes=30)
cursor.execute(f'select * from free_drink_list_history where timestamp>="{timestamp}" and (user_id={user.id} or free_drink_type_id=3)')
retVal = cursor.fetchall() retVal = cursor.fetchall()
for data in retVal: for data in retVal:
data['timestamp'] = {'year': data['timestamp'].year, data['timestamp'] = {'year': data['timestamp'].year,