Update shipment tracking logic and debugging output

- Adjusted shipment tracking logic in `start_loop` function.
- Added logging output for the number of events retrieved for a tracking number.
This commit is contained in:
Kumi 2023-08-23 10:43:34 +02:00
parent 1a8d5608a0
commit d09daaa0cc
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -221,10 +221,11 @@ def start_loop(db: sqlite3.Connection, api: KeyDelivery) -> Never:
logging.debug(f"Checking shipment {tracking_number} with carrier {carrier}")
latest_known_event = get_latest_event(db, shipment_id)
all_events = api.realtime(carrier, tracking_number)
try:
logging.debug(f"Got events for {tracking_number}: {len(all_events)}")
logging.debug(f"Got events for {tracking_number}: {len(all_events['data']['items'])}")
except KeyError:
print(f"Error getting events for {tracking_number}: {all_events}")
continue