Skip to content

Commit

Permalink
addition of functionality for the new catalog data for UI V3
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Apr 24, 2024
1 parent f3ff59c commit fa2f5d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/common/pg_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ def get_terria_map_catalog_data(self, **kwargs):
else:
wb_sql: str = ""

# get the correct sp name
if kwargs['use_v3_sp']:
sp_name: str = 'public.get_terria_data_json_v3'
else:
sp_name: str = 'public.get_terria_data_json'

# create the sql
sql: str = f"SELECT public.get_terria_data_json(_grid_type:={kwargs['grid_type']}, _event_type:={kwargs['event_type']}, " \
sql: str = f"SELECT {sp_name}(_grid_type:={kwargs['grid_type']}, _event_type:={kwargs['event_type']}, " \
f"_instance_name:={kwargs['instance_name']}, _run_date:={kwargs['run_date']}, _end_date:={kwargs['end_date']}, " \
f"_limit:={kwargs['limit']}, _met_class:={kwargs['met_class']}, _storm_name:={kwargs['storm_name']}, " \
f"_cycle:={kwargs['cycle']}, _advisory_number:={kwargs['advisory_number']}, _project_code:={kwargs['project_code']}, " \
Expand Down
24 changes: 21 additions & 3 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
advisory_number: Union[str, None] = Query(default=None), run_date: Union[str, None] = Query(default=None),
end_date: Union[str, None] = Query(default=None), project_code: Union[str, None] = Query(default=None),
product_type: Union[str, None] = Query(default=None), limit: Union[int, None] = Query(default=7),
use_new_wb: Union[bool, None] = Query(default=False)) -> json:
use_new_wb: Union[bool, None] = Query(default=False),
use_v3_sp: Union[bool, None] = Query(default=False)
) -> json:
"""
Gets the json formatted terria map UI catalog data.
<br/>Note: Leave filtering params empty if not desired.
Expand All @@ -77,6 +79,7 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
<br/>&nbsp;&nbsp;&nbsp;product_type: Filter by the product type
<br/>&nbsp;&nbsp;&nbsp;limit: Limit the number of catalog records returned in days (default is 7)
<br/>&nbsp;&nbsp;&nbsp;use_new_wb: Use the new catalog workbench code
<br/>&nbsp;&nbsp;&nbsp;use_v3_sp: Use the new v3 data stored procedure
"""
# pylint: disable=unused-argument
# pylint: disable=too-many-arguments
Expand All @@ -102,6 +105,9 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
# add in the new workbench retrieval flag
kwargs.update({'use_new_wb': use_new_wb})

# add in the new workbench retrieval flag
kwargs.update({'use_v3_sp': use_v3_sp})

# try to make the call for records
ret_val = db_info.get_terria_map_catalog_data(**kwargs)

Expand Down Expand Up @@ -220,7 +226,9 @@ async def get_terria_map_catalog_data_secure(grid_type: Union[str, None] = Query
project_code: Union[str, None] = Query(default=None),
product_type: Union[str, None] = Query(default=None),
limit: Union[int, None] = Query(default=7),
use_new_wb: Union[bool, None] = Query(default=False)) -> json:
use_new_wb: Union[bool, None] = Query(default=False),
use_v3_sp: Union[bool, None] = Query(default=False),
) -> json:
"""
Gets the json formatted terria map UI catalog data.
<br/>Note: Leave filtering params empty if not desired.
Expand All @@ -237,6 +245,7 @@ async def get_terria_map_catalog_data_secure(grid_type: Union[str, None] = Query
<br/>&nbsp;&nbsp;&nbsp;product_type: Filter by the product type
<br/>&nbsp;&nbsp;&nbsp;limit: Limit the number of catalog records returned in days (default is 7)
<br/>&nbsp;&nbsp;&nbsp;use_new_wb: Use the new catalog workbench code
<br/>&nbsp;&nbsp;&nbsp;use_v3_sp: Use the new v3 data stored procedure
"""
# init the returned data and html status code
ret_val: dict = {}
Expand All @@ -263,6 +272,9 @@ async def get_terria_map_catalog_data_secure(grid_type: Union[str, None] = Query
# add in the new workbench retrieval flag
kwargs.update({'use_new_wb': use_new_wb})

# add in the new workbench retrieval flag
kwargs.update({'use_v3_sp': use_v3_sp})

# try to make the call for records
ret_val = db_info.get_terria_map_catalog_data(**kwargs)

Expand Down Expand Up @@ -302,7 +314,9 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
advisory_number: Union[str, None] = Query(default=None), run_date: Union[str, None] = Query(default=None),
end_date: Union[str, None] = Query(default=None), project_code: Union[str, None] = Query(default=None),
product_type: Union[str, None] = Query(default=None), limit: Union[int, None] = Query(default=7),
use_new_wb: Union[bool, None] = Query(default=False)) -> json:
use_new_wb: Union[bool, None] = Query(default=False),
use_v3_sp: Union[bool, None] = Query(default=False),
) -> json:
"""
Returns the json formatted terria map UI catalog data in a file specified.
<br/>Note: Leave filtering params empty if not desired.
Expand All @@ -320,6 +334,7 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
<br/>&nbsp;&nbsp;&nbsp;product_type: Filter by the product type
<br/>&nbsp;&nbsp;&nbsp;limit: Limit the number of catalog records returned in days (default is 7)
<br/>&nbsp;&nbsp;&nbsp;use_new_wb: Use the new catalog workbench code
<br/>&nbsp;&nbsp;&nbsp;use_v3_sp: Use the new v3 data stored procedure
"""
# pylint: disable=unused-argument
# pylint: disable=too-many-arguments
Expand All @@ -343,6 +358,9 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
# add in the new workbench retrieval flag
kwargs.update({'use_new_wb': use_new_wb})

# add in the new workbench retrieval flag
kwargs.update({'use_v3_sp': use_v3_sp})

# get a file path to the temp file directory.
# append a unique path to avoid collisions
temp_file_path: str = os.path.join(os.getenv('TEMP_FILE_PATH', os.path.dirname(__file__)), str(uuid.uuid4()))
Expand Down

0 comments on commit fa2f5d1

Please sign in to comment.