diff --git a/src/lvmapi/routers/transparency.py b/src/lvmapi/routers/transparency.py index 2ea6aca..2279f0a 100644 --- a/src/lvmapi/routers/transparency.py +++ b/src/lvmapi/routers/transparency.py @@ -47,7 +47,7 @@ class TransparencyData(BaseModel): zero_point: Annotated[float, Field(description="Zero-point value")] -@router.get("/", summary="Transparency measurements") +@router.get("", summary="Transparency measurements") async def route_get_transparency( start_time: Annotated[ float | None, diff --git a/src/lvmapi/tools/transparency.py b/src/lvmapi/tools/transparency.py index 174c871..f56d6f3 100644 --- a/src/lvmapi/tools/transparency.py +++ b/src/lvmapi/tools/transparency.py @@ -24,13 +24,22 @@ async def get_transparency(start_time: float, end_time: float): |> yield(name: "mean") """ + SCHEMA: dict[str, polars.DataType] = { + "time": polars.Datetime(time_unit="ms", time_zone="UTC"), + "telescope": polars.String(), + "zero_point": polars.Float32(), + } + data = await query_influxdb(query) + if len(data) == 0: + return polars.DataFrame(None, schema=SCHEMA) + # Clean up the dataframe. data = data.select( time=polars.col._time, telescope=polars.col._measurement.str.extract(r"lvm\.([a-z]+)\.guider"), zero_point=polars.col._value, - ) + ).cast(SCHEMA) # type: ignore return data