diff --git a/src/pg_utils.py b/src/pg_utils.py index 95b69d8..00797cb 100644 --- a/src/pg_utils.py +++ b/src/pg_utils.py @@ -248,7 +248,7 @@ def reset_job_order(self): if not failed: self.conn.commit() - def get_terria_map_catalog_data(self, grid_type, event_type, instance_name, run_date, limit): + def get_terria_map_catalog_data(self, grid_type, event_type, instance_name, run_date, end_date, limit): """ gets the catalog data for the terria map UI @@ -256,7 +256,7 @@ def get_terria_map_catalog_data(self, grid_type, event_type, instance_name, run_ """ # create the sql - sql: str = f'SELECT public.get_terria_data_json(_grid_type:={grid_type}, _event_type:={event_type}, _instance_name:={instance_name}, _run_date:={run_date}, _limit:={limit})' + sql: str = f'SELECT public.get_terria_data_json(_grid_type:={grid_type}, _event_type:={event_type}, _instance_name:={instance_name}, _run_date:={run_date}, _end_date:={end_date}, _limit:={limit})' # get the data return self.exec_sql(sql)[0][0] diff --git a/src/server.py b/src/server.py index ca4599b..c4ac962 100644 --- a/src/server.py +++ b/src/server.py @@ -21,7 +21,7 @@ from src.pg_utils import PGUtils # set the app version -APP_VERSION = 'v0.0.15' +APP_VERSION = 'v0.0.16' # get the log level and directory from the environment. # level comes from the container dockerfile, path comes from the k8s secrets @@ -311,7 +311,8 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul event_type: Union[str, None] = Query(default=None), instance_name: Union[str, None] = Query(default=None), run_date: Union[str, None] = Query(default=None), - limit: Union[int, None] = Query(default=2)) -> json: + end_date: Union[str, None] = Query(default=None), + limit: Union[int, None] = Query(default=4)) -> json: """ Gets the json formatted terria map UI catalog data.
Note: Leave filtering params empty if not desired. @@ -319,7 +320,8 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
   event_type: Filter by the event type
   instance_name: Filter by the name of the ASGS instance
   run_date: Filter by the run date in the form of yyyy-mm-dd -
   limit: Limit the number of catalog records returned (default is 2) +
   end_date: Filter by the data between the run date and end date +
   limit: Limit the number of catalog records returned (default is 4) """ # init the returned html status code @@ -334,9 +336,10 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul event_type = 'null' if not event_type else f"'{event_type}'" instance_name = 'null' if not instance_name else f"'{instance_name}'" run_date = 'null' if not run_date else f"'{run_date}'" + end_date = 'null' if not end_date else f"'{end_date}'" # try to make the call for records - ret_val = pg_db.get_terria_map_catalog_data(grid_type, event_type, instance_name, run_date, limit) + ret_val = pg_db.get_terria_map_catalog_data(grid_type, event_type, instance_name, run_date, end_date, limit) except Exception as e: # return a failure message ret_val = f'Exception detected trying to get the terria map catalog data.' @@ -357,7 +360,8 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d event_type: Union[str, None] = Query(default=None), instance_name: Union[str, None] = Query(default=None), run_date: Union[str, None] = Query(default=None), - limit: Union[int, None] = Query(default=2)) -> FileResponse: + end_date: Union[str, None] = Query(default=None), + limit: Union[int, None] = Query(default=4)) -> FileResponse: """ Returns the json formatted terria map UI catalog data in a file specified.
Note: Leave filtering params empty if not desired. @@ -366,6 +370,7 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
   event_type: Filter by the event type
   instance_name: Filter by the name of the ASGS instance
   run_date: Filter by the run date in the form of yyyy-mm-dd +
   end_date: Filter by the data between the run date and end date
   limit: Limit the number of catalog records returned (default is 2) """ # init the returned html status code @@ -379,13 +384,14 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d event_type = 'null' if not event_type else f"'{event_type}'" instance_name = 'null' if not instance_name else f"'{instance_name}'" run_date = 'null' if not run_date else f"'{run_date}'" + end_date = 'null' if not end_date else f"'{end_date}'" try: # create the postgres access object pg_db = PGUtils(apsviz_dbname, apsviz_username, apsviz_password) # try to make the call for records - ret_val = pg_db.get_terria_map_catalog_data(grid_type, event_type, instance_name, run_date, limit) + ret_val = pg_db.get_terria_map_catalog_data(grid_type, event_type, instance_name, run_date, end_date, limit) # write out the data to a file with open(file_path, 'w') as fp: