Skip to content

Commit

Permalink
adding method to get the run ids for tropical runs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Apr 13, 2023
1 parent 93b963c commit 5e58c6e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/common/pg_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ def __del__(self):
# clean up connections and cursors
PGUtilsMultiConnect.__del__(self)

def get_tropical_member_id(self, run_date):
"""
gets the ids for tropical runs for the date given.
:return:
"""
# create the sql
sql: str = f"SELECT get_tropical_member_id('{run_date}')"

# get the list of ids
tropical_id_list = self.exec_sql('apsviz', sql)

# no data results in a null returned
if tropical_id_list == -1:
tropical_id_list = []

# return the data
return tropical_id_list

def get_terria_map_catalog_data(self, **kwargs):
"""
gets the catalog data for the terria map UI
Expand Down
29 changes: 28 additions & 1 deletion src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from src.common.pg_impl import PGImplementation

# set the app version
APP_VERSION = 'v0.3.10'
APP_VERSION = 'v0.3.11'

# declare the FastAPI details
APP = FastAPI(title='APSVIZ UI Data', version=APP_VERSION)
Expand Down Expand Up @@ -311,6 +311,33 @@ async def get_pulldown_data(grid_type: Union[str, None] = Query(default=None), e
# return to the caller
return JSONResponse(content=ret_val, status_code=status_code, media_type="application/json")


@APP.get('/get_tropical_member_id', status_code=200, response_model=None)
async def get_tropical_member_id(run_date: Union[str, None] = Query(default=None)) -> json:
"""
Gets the json formatted tropical run IDs for the day.
<br/>&nbsp;&nbsp;&nbsp;run_date: Filter by the run date in the form of yyyy-mm-dd
"""
# init the returned html status code
status_code: int = 200

try:
# try to make the call for records
ret_val: dict = db_info.get_tropical_member_id(run_date)
except Exception:
# return a failure message
ret_val: str = 'Exception detected trying to get the get tropical member id list.'

# log the exception
logger.exception(ret_val)

# set the status to a server error
status_code = 500

# return to the caller
return JSONResponse(content=ret_val, status_code=status_code, media_type="application/json")

# async def get_run_prop_urls(source_type: Union[str, None] = Query(default=None), run_date: Union[str, None] = Query(default=''),
# end_date: Union[str, None] = Query(default='')) -> json:
# """
Expand Down

0 comments on commit 5e58c6e

Please sign in to comment.