Refactor event loop for trackbert.py

- Improve conditional check for latest known event timestamp in the event loop.
- Update the index of the `latest_known_event` timestamp from position 3 to position 2 for accurate comparison.
- This ensures that only events with a more recent timestamp are considered.
This commit is contained in:
Kumi 2023-08-21 09:02:30 +02:00
parent 053ae780e1
commit 69e5023994
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -227,7 +227,7 @@ def start_loop(db: sqlite3.Connection, api: KeyDelivery) -> Never:
logging.debug(f"Latest upstream event for {tracking_number}: {events[0]['context']} - {events[0]['time']}")
for event in events:
if latest_known_event is None or event["time"] > latest_known_event[3]:
if latest_known_event is None or event["time"] > latest_known_event[2]:
create_event(
db,
shipment_id,