Refactor event sorting and logging in Tracker class

- Sort events in descending order based on event time.
- Update debug logging message to include event description and time.
This commit is contained in:
Kumi 2023-08-24 14:48:21 +02:00
parent 1ae1a88975
commit e71a30630d
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -89,6 +89,7 @@ class Tracker:
latest_known_event = self.db.get_latest_event(shipment_id)
events = self.query_api(tracking_number, carrier)
events = sorted(events, key=lambda x: x.event_time, reverse=True)
if latest_known_event:
logging.debug(f"Latest known event for {tracking_number}: {latest_known_event.event_description} - {latest_known_event.event_time}")