From b588931b583ff7f653d5b0c870f95764ebfe6daa Mon Sep 17 00:00:00 2001 From: Mohammad Etemaddar Date: Tue, 1 Nov 2022 14:21:07 +0100 Subject: [PATCH 1/5] [FIX] get system status --- app/api/src/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/src/main.py b/app/api/src/main.py index 2c06619ba..e9a64aab8 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 == "maintenance": return JSONResponse(status_code=503, content={"message": "Service Unavailable"}) else: return {"status": "ok"} From c7456fc4a4750d818f620dced10c1626b5657adb Mon Sep 17 00:00:00 2001 From: Mohammad Etemaddar Date: Tue, 1 Nov 2022 14:21:39 +0100 Subject: [PATCH 2/5] [ADD] put method to update system status --- app/api/src/endpoints/v1/api.py | 2 ++ app/api/src/endpoints/v1/system.py | 25 +++++++++++++++++++++++++ app/api/src/resources/enums.py | 5 +++++ app/api/src/schemas/system.py | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100644 app/api/src/endpoints/v1/system.py create mode 100644 app/api/src/schemas/system.py 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..e2b9dd0f8 --- /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.status + system = await crud.system.update(db, db_obj=system, obj_in=system) + + return SystemStatusModel(status=system.setting) 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 From 54a6b054e2162f7e002120d2c167786eb490900b Mon Sep 17 00:00:00 2001 From: Mohammad Etemaddar Date: Tue, 1 Nov 2022 22:57:08 +0100 Subject: [PATCH 3/5] [FIX] system status structure at endpoint --- app/api/src/endpoints/v1/system.py | 4 ++-- app/api/src/main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/src/endpoints/v1/system.py b/app/api/src/endpoints/v1/system.py index e2b9dd0f8..2afc2d553 100644 --- a/app/api/src/endpoints/v1/system.py +++ b/app/api/src/endpoints/v1/system.py @@ -19,7 +19,7 @@ async def status_check( ): results = await crud.system.get_by_key(db, key="type", value="status") system = results[0] - system.setting = status_in.status + system.setting = status_in.dict() system = await crud.system.update(db, db_obj=system, obj_in=system) - return SystemStatusModel(status=system.setting) + return system.setting diff --git a/app/api/src/main.py b/app/api/src/main.py index e9a64aab8..ebf6ace54 100644 --- a/app/api/src/main.py +++ b/app/api/src/main.py @@ -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 == "maintenance": + if results.setting.get("status") == "maintenance": return JSONResponse(status_code=503, content={"message": "Service Unavailable"}) else: return {"status": "ok"} From 426cb983412258e0afaddebb65971c28b1b95012 Mon Sep 17 00:00:00 2001 From: Ebubeker Rexha <60944813+Ebubeker@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:38:23 +0100 Subject: [PATCH 4/5] fixed the isochrone bug --- .../isochrones/IsochroneThematicData.vue | 21 +++++++++++-- .../src/components/isochrones/Isochrones.vue | 30 +++++++------------ app/client/src/utils/Helpers.js | 6 ++++ 3 files changed, 36 insertions(+), 21 deletions(-) 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]) + }} - {{ - calculateCalculationsLength() - - calculateCurrentIndex(calculation) - }} + {{ getCurrentIsochroneNumber(calculation) }} #${calculationId} ${this.$t( - "isochrones.options.time" - )}: ${time} min`; + overlayerInnerHtml += `
#${this.getCurrentIsochroneNumber( + calculation + )} ${this.$t("isochrones.options.time")}: ${time} min
`; } if (features.length === 2 && index == 0) { overlayerInnerHtml += `
`; @@ -2003,17 +2004,8 @@ export default { this.clear(); }, //! Clculate the real length of the calculations array - calculateCalculationsLength() { - let realArr = this.calculations.filter( - calculation => calculation !== "deleted" - ); - return realArr.length; - }, - calculateCurrentIndex(calc) { - let realArr = this.calculations.filter( - calculation => calculation !== "deleted" - ); - return realArr.indexOf(calc); + getCurrentIsochroneNumber(calc) { + return calculateCalculationsLength() - calculateCurrentIndex(calc); } }, watch: { diff --git a/app/client/src/utils/Helpers.js b/app/client/src/utils/Helpers.js index 812034921..0501d85b4 100644 --- a/app/client/src/utils/Helpers.js +++ b/app/client/src/utils/Helpers.js @@ -273,3 +273,9 @@ export function calculateRealCalculations() { ); return realArr; } +export function calculateCurrentIndex(calc) { + let realArr = store.state.isochrones.calculations.filter( + calculation => calculation !== "deleted" + ); + return realArr.indexOf(calc); +} From 25325f78263da6d5be2539c74182d3c125e9cf93 Mon Sep 17 00:00:00 2001 From: Elias Pajares <42171996+EPajares@users.noreply.github.com> Date: Sun, 6 Nov 2022 22:42:05 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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