From 604ebef78c496aa63ada64fdebd622da9351c326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20H=2E=20Garc=C3=ADa?= Date: Fri, 26 Jul 2024 15:30:15 -0600 Subject: [PATCH] Avoiding pop() --- app/actions/handlers.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/actions/handlers.py b/app/actions/handlers.py index 9362791..4baa67e 100644 --- a/app/actions/handlers.py +++ b/app/actions/handlers.py @@ -18,17 +18,18 @@ async def filter_and_transform(devices, integration_id, action_id): def transform(device): - device_id = device.pop("Imeino") - device_name = device.pop("Vehicle_Name") + device_id = device.get("Imeino") + device_name = device.get("Vehicle_Name") recorded_at = datetime.datetime.strptime( - device.pop("GPSActualTime"), + device.get("GPSActualTime"), '%d-%m-%Y %H:%M:%S' ).replace(tzinfo=datetime.timezone.utc) - lat = device.pop("Latitude") - lon = device.pop("Longitude") + lat = device.get("Latitude") + lon = device.get("Longitude") - additional = {k: v for k, v in device.items() if v and v != "--"} + base_fields = ["Imeino", "Vehicle_Name", "GPSActualTime", "Latitude", "Longitude"] + additional = {k: v for k, v in device.items() if k not in base_fields and v and v != "--"} return { "source": device_id,