1- from typing import Any , Iterable , List , Union , Optional
1+ from typing import Any , Iterable , List , Optional , Union
22
33import dotenv
44import httpx
@@ -54,6 +54,7 @@ def _dt_to_ms(dt: Optional[datetime]) -> Optional[int]:
5454 dt = dt .replace (tzinfo = timezone .utc )
5555 return int (dt .timestamp () * 1000 )
5656
57+
5758def _dt_to_iso_z (dt : Optional [datetime ]) -> Optional [str ]:
5859 if not dt :
5960 return None
@@ -62,7 +63,6 @@ def _dt_to_iso_z(dt: Optional[datetime]) -> Optional[str]:
6263 return dt .astimezone (timezone .utc ).isoformat ().replace ("+00:00" , "Z" )
6364
6465
65-
6666def _format_checkin_date (dt : Optional [datetime ]) -> Optional [str ]:
6767 """Match example Rockd checkin date strings like 'October 19, 2023'."""
6868 if not dt :
@@ -287,25 +287,27 @@ def multiple_spot_to_fieldsite(
287287 return out
288288
289289
290- def spot_to_checkin (spot : Union [dict , List [dict ]] = Body (...)) -> Union [dict , list [dict ]]:
290+ def spot_to_checkin (
291+ spot : Union [dict , List [dict ]] = Body (...)
292+ ) -> Union [dict , list [dict ]]:
291293 """Pipeline: Spot JSON (FeatureCollections) or FieldSites -> Checkin(s).
292294 Output rule:
293295 - dict output only when the input is a single object representing a single spot/fieldsite
294296 (Feature OR FeatureCollection with exactly 1 feature OR single FieldSite dict)
295297 AND exactly one checkin is produced.
296298 - otherwise list output
297299 """
298- #multiple fieldsites
300+ # multiple fieldsites
299301 if isinstance (spot , list ):
300302 if spot and isinstance (spot [0 ], dict ) and "location" in spot [0 ]:
301303 return multiple_fieldsite_to_rockd_checkin (spot )
302304 fieldsites = multiple_spot_to_fieldsite (spot )
303305 return multiple_fieldsite_to_rockd_checkin (fieldsites )
304- #single fieldsite object
306+ # single fieldsite object
305307 if isinstance (spot , dict ) and "location" in spot :
306308 checkins = multiple_fieldsite_to_rockd_checkin ([spot ])
307309 return checkins [0 ] if len (checkins ) == 1 else checkins
308- #determine whether this is a single spot
310+ # determine whether this is a single spot
309311 is_single_spot_payload = False
310312 if isinstance (spot , dict ):
311313 t = spot .get ("type" )
@@ -322,8 +324,6 @@ def spot_to_checkin(spot: Union[dict, List[dict]] = Body(...)) -> Union[dict, li
322324 return checkins
323325
324326
325-
326-
327327# ___________________________________CHECKIN - FS - SPOT____________________________________
328328def checkin_to_fieldsite (checkin : dict ) -> FieldSite :
329329 """
@@ -360,10 +360,11 @@ def checkin_to_fieldsite(checkin: dict) -> FieldSite:
360360 observations .append (Observation (data = planar ))
361361 created = _parse_date_time (checkin .get ("created" )) or datetime .now (timezone .utc )
362362
363- updated = (_parse_date_time (checkin .get ("updated" ))
364- or _parse_date_time (checkin .get ("added" ))
365- or created
366- )
363+ updated = (
364+ _parse_date_time (checkin .get ("updated" ))
365+ or _parse_date_time (checkin .get ("added" ))
366+ or created
367+ )
367368
368369 return FieldSite (
369370 id = int (cid ),
0 commit comments