From 70f8b43d9ccf4ab0acae349d6df8f8d42f41312a Mon Sep 17 00:00:00 2001 From: Nico Vermaas <vermaas@astron.nl> Date: Fri, 2 Sep 2022 14:17:54 +0200 Subject: [PATCH] add '/adex-fastapi' prefix to router --- README.md | 3 ++- routers/skyviews.py | 5 +++-- utils/convert_alta_to_adex_cache.py | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f8ab9b..229bac8 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ ## Development ### localhost (laptop) * http://localhost:8000/adex-fastapi/skyviews/ - * http://localhost:8000/adex-fastapi/skyviews_rectangle/?ra_min=70&ra_max=90&dec_min=15&dec_max=17&limit=10000 + * http://localhost:8000/adex-fastapi/skyviews_rectangle/?ra_min=40&ra_max=50&dec_min=25&dec_max=35&limit=1000 ### sdc-dev (test environment) * https://sdc-dev.astron.nl/adex-fastapi/skyviews/ + * https://sdc-dev.astron.nl/adex-fastapi/skyviews_rectangle/?ra_min=40&ra_max=50&dec_min=25&dec_max=35&limit=1000 ## data procedures (rough) * [dump/load a copy of the alta database](https://web-of-wyrd.nl/myworkwiki/doku.php?id=alta_runtime&s[]=dump#qhow_do_i_dump_and_load_a_copy_of_the_production_database_with_postgres_into_a_dev_or_vm_environment) diff --git a/routers/skyviews.py b/routers/skyviews.py index e4ca893..29b7abc 100644 --- a/routers/skyviews.py +++ b/routers/skyviews.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import Session from database import crud, models, schemas from database.database import SessionLocal, engine -router = APIRouter(tags=["skyviews"],) +router = APIRouter(prefix="/adex-fastapi", tags=["skyviews"],) # Dependency def get_db(): @@ -18,11 +18,12 @@ def get_db(): # http://127.0.0.1:8000/skyviews/ # http://127.0.0.1:8000/skyviews/?skip=100&limit=100 -@router.get("/adex-fastapi/skyviews/", tags=["skyviews"], response_model=List[schemas.SkyView]) +@router.get("/skyviews/", tags=["skyviews"], response_model=List[schemas.SkyView]) async def get_skyviews(skip: int = 0, limit: int = 1000, db: Session = Depends(get_db)): items = crud.get_skyviews(db, skip=skip, limit=limit) return items +# http://localhost:8000/adex-fastapi/skyviews_rectangle/?ra_min=40&ra_max=50&dec_min=25&dec_max=35&limit=1000 @router.get("/skyviews_rectangle/", tags=["skyviews"], response_model=List[schemas.SkyView]) async def get_skyviews_rectangle(ra_min: float = 0.0, ra_max: float = 1.0, dec_min: float = 0.0, dec_max: float = 1.0, diff --git a/utils/convert_alta_to_adex_cache.py b/utils/convert_alta_to_adex_cache.py index 9afeb4f..4fcd49b 100644 --- a/utils/convert_alta_to_adex_cache.py +++ b/utils/convert_alta_to_adex_cache.py @@ -58,6 +58,7 @@ def do_convert(source, target): record_to_insert = (observation, observation, ra, dec, "alta",0, dt,dst, access_url) target_cursor.execute(insert_into_skyview,record_to_insert) target_connection.commit() + except Error as e: print(e) -- GitLab