Skip to content

Commit

Permalink
Rename router world map
Browse files Browse the repository at this point in the history
  • Loading branch information
katybaulch committed Nov 28, 2024
1 parent 9078770 commit b2a3671
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from fastapi import APIRouter, Depends, Header, HTTPException, Request, status

from app.clients.db.session import get_db
from app.errors import RepositoryError
from app.errors import RepositoryError, ValidationError
from app.models.geography import GeographyStatsDTO
from app.service.custom_app import AppTokenFactory
from app.service.world_map import get_world_map_stats

_LOGGER = logging.getLogger(__file__)

geographies_router = APIRouter()
world_map_router = APIRouter()


@geographies_router.get("/geographies", response_model=list[GeographyStatsDTO])
@world_map_router.get("/geographies", response_model=list[GeographyStatsDTO])
async def geographies(
request: Request, app_token: Annotated[str, Header()], db=Depends(get_db)
):
Expand Down Expand Up @@ -42,6 +42,10 @@ async def geographies(

return world_map_stats
except RepositoryError as e:
_LOGGER.error(e)
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE, detail=e.message
)
except ValidationError as e:
_LOGGER.error(e)
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=e.message)
4 changes: 2 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from app.api.api_v1.routers.admin import admin_document_router
from app.api.api_v1.routers.auth import auth_router
from app.api.api_v1.routers.documents import documents_router
from app.api.api_v1.routers.geographies import geographies_router
from app.api.api_v1.routers.lookups import lookups_router
from app.api.api_v1.routers.pipeline_trigger import pipeline_trigger_router
from app.api.api_v1.routers.search import search_router
from app.api.api_v1.routers.summaries import summary_router
from app.api.api_v1.routers.world_map import world_map_router
from app.clients.db.session import SessionLocal, engine
from app.service.auth import get_superuser_details
from app.service.health import is_database_online
Expand Down Expand Up @@ -158,7 +158,7 @@ async def root():
summary_router, prefix="/api/v1", tags=["Summaries"], include_in_schema=False
)
app.include_router(
geographies_router, prefix="/api/v1", tags=["Geographies"], include_in_schema=False
world_map_router, prefix="/api/v1", tags=["Geographies"], include_in_schema=False
)

# add pagination support to all routes that ask for it
Expand Down

0 comments on commit b2a3671

Please sign in to comment.