Skip to content

Commit 1c47c99

Browse files
committed
Fixes bug whereby when not submitting an in_MAC or out_MAC would result in the database being searched regardless, comparing the contents to a non-existent value. This resulted in invalid json being added to the payload sent to the api and certain requests to fail. This patch, makes it so the database is only queried when there is an in_MAC or out_MAC specified by the user.
1 parent a50b474 commit 1c47c99

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

move_by_attribute/process_move.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
LOGOUT_MAC = args.out_MAC
2626

2727
to_seat_id = 0
28-
if (len(table_macs_to_seats.search(Query().mac == LOGIN_MAC)) > 0):
29-
to_seat_id = table_macs_to_seats.search(Query().mac == LOGIN_MAC)[0]['seat']
28+
if LOGIN_MAC:
29+
if (len(table_macs_to_seats.search(Query().mac == LOGIN_MAC)) > 0):
30+
to_seat_id = table_macs_to_seats.search(Query().mac == LOGIN_MAC)[0]['seat']
3031

3132
from_seat_id = 0
32-
if (len(table_macs_to_seats.search(Query().mac == LOGOUT_MAC)) > 0):
33-
from_seat_id = table_macs_to_seats.search(Query().mac == LOGOUT_MAC)[0]['seat']
33+
if LOGOUT_MAC:
34+
if (len(table_macs_to_seats.search(Query().mac == LOGOUT_MAC)) > 0):
35+
from_seat_id = table_macs_to_seats.search(Query().mac == LOGOUT_MAC)[0]['seat']
3436

3537
move_body = {'employee_id': EMPLOYEE_EMAIL.split('@', 1)[0],
3638
'move_time': str(datetime.datetime.now().replace(microsecond=0)),
@@ -55,4 +57,4 @@
5557

5658
response = requests.put(conf.URL_BASE + conf.URL_MOVES + '/' + str(move_id) + '/complete', headers=conf.HEADERS)
5759

58-
print(str(response.status_code) + ': ' + response.reason)
60+
print(str(response.status_code) + ': ' + response.reason)

0 commit comments

Comments
 (0)