Fix latest known event logging
- The code now checks if there is a latest known event before logging it. If there is no latest known event, it logs "No known events for {tracking_number}". - The logging for the latest known event now includes the event description and name. - This change improves the logging output for the latest known event, making it more informative.
This commit is contained in:
parent
d09daaa0cc
commit
ebcb3ef6aa
1 changed files with 5 additions and 1 deletions
|
@ -232,7 +232,11 @@ def start_loop(db: sqlite3.Connection, api: KeyDelivery) -> Never:
|
||||||
|
|
||||||
events = sorted(all_events["data"]["items"], key=lambda x: x["time"], reverse=True)
|
events = sorted(all_events["data"]["items"], key=lambda x: x["time"], reverse=True)
|
||||||
|
|
||||||
logging.debug(f"Latest known event for {tracking_number}: {latest_known_event[3]} - {latest_known_event[2]}")
|
if latest_known_event:
|
||||||
|
logging.debug(f"Latest known event for {tracking_number}: {latest_known_event[3]} - {latest_known_event[2]}")
|
||||||
|
else:
|
||||||
|
logging.debug(f"No known events for {tracking_number}")
|
||||||
|
|
||||||
logging.debug(f"Latest upstream event for {tracking_number}: {events[0]['context']} - {events[0]['time']}")
|
logging.debug(f"Latest upstream event for {tracking_number}: {events[0]['context']} - {events[0]['time']}")
|
||||||
|
|
||||||
latest = True
|
latest = True
|
||||||
|
|
Loading…
Reference in a new issue