diff --git a/README.md b/README.md index 4980c59ac..ef12297c1 100644 --- a/README.md +++ b/README.md @@ -40,4 +40,6 @@ Pajares, E.; Muñoz Nieto, R.; Meng, L.; Wulfhorst, G. Population Disaggregation Pajares, E., Jehle, U., 2021. GOAT: Ein interaktives Erreichbarkeitsinstrument zur Planung der 15-Minuten-Stadt, in: Flächennutzungsmonitoring XIII: Flächenpolitik - Konzepte - Analysen - Tools, IÖR Schriften. Rhombos-Verlag, Berlin, pp. 265–273. https://doi.org/10.26084/13dfns-p024 +Pajares, E., Jehle, U., Hall, J., Miramontes, M., Wulfhorst, G., 2022. Assessment of the usefulness of the accessibility instrument GOAT for the planning practice. Journal of Urban Mobility 2, 100033. https://doi.org/10.1016/j.urbmob.2022.100033 + Jehle, U., Pajares, E., Analyse der Fußwegequalitäten zu Schulen – Entwicklung von Indikatoren auf Basis von OpenData. In: Meinel, G.; Krüger, T.; Behnisch, M.; Ehrhardt, D. (Hrsg.): Flächennutzungsmonitoring XIII: Flächenpolitik - Konzepte - Analysen - Tools. Berlin: Rhombos-Verlag, 2021, (IÖR-Schriften Band 79), S.221-232, https://doi.org/10.26084/13dfns-p020 diff --git a/app/api/src/endpoints/v1/api.py b/app/api/src/endpoints/v1/api.py index bb39ff6d5..19b5a32ff 100644 --- a/app/api/src/endpoints/v1/api.py +++ b/app/api/src/endpoints/v1/api.py @@ -18,6 +18,7 @@ static_layers, static_layers_extra, study_area, + system, upload, users, utils, @@ -25,6 +26,7 @@ api_router = APIRouter() api_router.include_router(login.router, tags=["Login"]) +api_router.include_router(system.router, prefix="", tags=["Health Check"]) api_router.include_router(organizations.router, prefix="/organizations", tags=["Organizations"]) api_router.include_router(roles.router, prefix="/roles", tags=["Roles"]) diff --git a/app/api/src/endpoints/v1/system.py b/app/api/src/endpoints/v1/system.py new file mode 100644 index 000000000..2afc2d553 --- /dev/null +++ b/app/api/src/endpoints/v1/system.py @@ -0,0 +1,25 @@ +from typing import Any, List + +from fastapi import APIRouter, Depends, HTTPException +from sqlalchemy.ext.asyncio import AsyncSession + +from src import crud +from src.db import models +from src.endpoints import deps +from src.schemas.system import SystemStatusModel + +router = APIRouter() + + +@router.put("/status", response_model=SystemStatusModel) +async def status_check( + status_in: SystemStatusModel, + db: AsyncSession = Depends(deps.get_db), + current_user: models.User = Depends(deps.get_current_active_superuser), +): + results = await crud.system.get_by_key(db, key="type", value="status") + system = results[0] + system.setting = status_in.dict() + system = await crud.system.update(db, db_obj=system, obj_in=system) + + return system.setting diff --git a/app/api/src/main.py b/app/api/src/main.py index 2c06619ba..ebf6ace54 100644 --- a/app/api/src/main.py +++ b/app/api/src/main.py @@ -65,7 +65,7 @@ async def startup_event(): async with async_session() as db: table_index = await crud.layer.table_index(db) app.state.table_catalog = table_index - + if not os.environ.get("DISABLE_NUMBA_STARTUP_CALL") == "True": await run_time_method_calls.call_isochrones_startup(app=app) @@ -99,7 +99,7 @@ async def status_check(db: AsyncSession = Depends(deps.get_db)): except Exception as e: return JSONResponse(status_code=503, content={"message": "Service Unavailable"}) - if results.setting["status"] == "maintenance": + if results.setting.get("status") == "maintenance": return JSONResponse(status_code=503, content={"message": "Service Unavailable"}) else: return {"status": "ok"} diff --git a/app/api/src/resources/enums.py b/app/api/src/resources/enums.py index 82e8fdd3e..0343a3449 100644 --- a/app/api/src/resources/enums.py +++ b/app/api/src/resources/enums.py @@ -181,3 +181,8 @@ class LayerGroupsEnum(str, Enum): class GeostoreType(str, Enum): geoadmin = "geoadmin" other = "other" + + +class SystemStatus(str, Enum): + maintenance = "maintenance" + running = "running" diff --git a/app/api/src/schemas/system.py b/app/api/src/schemas/system.py new file mode 100644 index 000000000..4a8417046 --- /dev/null +++ b/app/api/src/schemas/system.py @@ -0,0 +1,7 @@ +from lib2to3.pytree import Base +from pydantic import BaseModel +from src.resources.enums import SystemStatus + + +class SystemStatusModel(BaseModel): + status: SystemStatus diff --git a/app/client/src/components/isochrones/IsochroneThematicData.vue b/app/client/src/components/isochrones/IsochroneThematicData.vue index f088d5764..e5f061f72 100644 --- a/app/client/src/components/isochrones/IsochroneThematicData.vue +++ b/app/client/src/components/isochrones/IsochroneThematicData.vue @@ -69,7 +69,12 @@ };` " > - Isochrone {{ selectedCalculations[0].id }} + Isochrone + {{ + getCurrentIsochroneNumber(selectedCalculations[0]) + }}
- Isochrone {{ selectedCalculations[1].id }} + Isochrone + {{ + getCurrentIsochroneNumber(selectedCalculations[1]) + }}