Refactor shipment_id assignment in Tracker and trackers/keydelivery.py

The shipment_id assignment has been refactored in the Tracker class and in the keydelivery.py file to set the value as 0 instead of using the tracking_number. This change ensures consistency in assigning the shipment_id across different trackers.
This commit is contained in:
Kumi 2023-08-24 15:33:09 +02:00
parent e71a30630d
commit a8a7522ff0
Signed by: kumi
GPG key ID: ECBCC9082395383F
3 changed files with 3 additions and 2 deletions

View file

@ -102,6 +102,7 @@ class Tracker:
for event in events: for event in events:
if latest_known_event is None or event.event_time > latest_known_event.event_time: if latest_known_event is None or event.event_time > latest_known_event.event_time:
event.shipment_id = shipment_id
self.db.write_event(event) self.db.write_event(event)
logging.info(f"New event for {tracking_number}: {event.event_description} - {event.event_time}") logging.info(f"New event for {tracking_number}: {event.event_description} - {event.event_time}")

View file

@ -24,7 +24,7 @@ class KeyDelivery(BaseTracker):
for event in events: for event in events:
yield Event( yield Event(
shipment_id = tracking_number, shipment_id = 0,
event_time = event["time"], event_time = event["time"],
event_description = event["context"], event_description = event["context"],
raw_event = json.dumps(event) raw_event = json.dumps(event)

View file

@ -21,7 +21,7 @@ class PostAT(BaseTracker):
py_timestamp = parse(timestamp) py_timestamp = parse(timestamp)
event_time = py_timestamp.strftime("%Y-%m-%d %H:%M:%S") event_time = py_timestamp.strftime("%Y-%m-%d %H:%M:%S")
yield Event( yield Event(
shipment_id = tracking_number, shipment_id = 0,
event_time = event_time, event_time = event_time,
event_description = event["text"], event_description = event["text"],
raw_event = json.dumps(event) raw_event = json.dumps(event)