+def backlog(imei, numback):
+ result = []
+ for is_incoming, timestamp, packet in fetch(
+ imei,
+ ((True, GPS_POSITIONING.PROTO), (False, WIFI_POSITIONING.PROTO)),
+ numback,
+ ):
+ msg = parse_message(packet, is_incoming=is_incoming)
+ result.append(
+ {
+ "type": "location",
+ "imei": imei,
+ "timestamp": str(
+ datetime.fromtimestamp(timestamp).astimezone(
+ tz=timezone.utc
+ )
+ ),
+ "longitude": msg.longitude,
+ "latitude": msg.latitude,
+ "accuracy": "gps"
+ if isinstance(msg, GPS_POSITIONING)
+ else "approximate",
+ }
+ )
+ return result
+
+