From 812948479caad60d5386d08acf1fe1946cd7ed75 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:43:59 -0700 Subject: [PATCH] Auto-update: Tue Jul 23 22:43:59 PDT 2024 --- sijapi/classes.py | 5 ++++- sijapi/routers/gis.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sijapi/classes.py b/sijapi/classes.py index 332f579..04eff65 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -489,7 +489,10 @@ class Location(BaseModel): datetime: lambda dt: dt.isoformat(), } - + def model_dump(self): + data = self.dict() + data["datetime"] = self.datetime.isoformat() if self.datetime else None + return data class Geocoder: diff --git a/sijapi/routers/gis.py b/sijapi/routers/gis.py index 8d8b937..cb0daf0 100644 --- a/sijapi/routers/gis.py +++ b/sijapi/routers/gis.py @@ -548,11 +548,11 @@ async def get_last_location_endpoint() -> JSONResponse: if this_location: location_dict = this_location.model_dump() - location_dict["datetime"] = this_location.datetime.isoformat() return JSONResponse(content=location_dict) else: raise HTTPException(status_code=404, detail="No location found before the specified datetime") + @gis.get("/locate/{datetime_str}", response_model=List[Location]) async def get_locate(datetime_str: str, all: bool = False): try: