From a8953e17b1a41434ba8a3661288a30d6738f53df Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Silva Date: Tue, 11 Jun 2024 18:30:51 +0100 Subject: [PATCH] Start adding /info endpoint --- arpav_ppcv/webapp/api_v2/routers/base.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arpav_ppcv/webapp/api_v2/routers/base.py b/arpav_ppcv/webapp/api_v2/routers/base.py index b7fc19fe..79a3e7a2 100644 --- a/arpav_ppcv/webapp/api_v2/routers/base.py +++ b/arpav_ppcv/webapp/api_v2/routers/base.py @@ -1,9 +1,16 @@ import importlib.metadata import logging import os +from typing import Annotated -from fastapi import APIRouter +import sqlmodel +from fastapi import ( + APIRouter, + Depends, +) +from .... import database +from ... import dependencies from ..schemas.base import AppInformation @@ -18,3 +25,16 @@ async def get_app_info(): "version": importlib.metadata.version("arpav_ppcv_backend"), "git_commit": os.getenv("GIT_COMMIT", "unknown"), } + + +@router.get("/info/{longitude}/{latitude") +def get_coordinates_info( + db_session: Annotated[sqlmodel.Session, Depends(dependencies.get_db_session)], + longitude: float, + latitude: float, +): + """Return information about a point location.""" + municipality = database.get_municipality_by_coordinates( + db_session, longitude, latitude + ) + logger.debug(f"{municipality=}")