diff --git a/src/common/pg_impl.py b/src/common/pg_impl.py index d65e73b..9b55e9a 100644 --- a/src/common/pg_impl.py +++ b/src/common/pg_impl.py @@ -212,3 +212,25 @@ def update_run_status(self, instance_id: int, uid: str, status: str): # if there were no errors, commit the updates if ret_val > -1: self.commit('asgs') + + def get_run_props(self, instance_id: int, uid: str): + """ + gets the run properties for a run + + :return: + """ + # create the sql + sql: str = f"SELECT * FROM public.get_run_prop_items_json({instance_id}, '{uid}')" + + # get the data + ret_val = self.exec_sql('asgs', sql) + + # check the result + if ret_val == -1: + ret_val = ['Run not found'] + else: + # replace with the data sorted by keys + ret_val[0]['run_data'] = {x: ret_val[0]['run_data'][x] for x in sorted(ret_val[0]['run_data'])} + + # return the data + return ret_val[0] diff --git a/src/server.py b/src/server.py index e87f6de..5a19009 100644 --- a/src/server.py +++ b/src/server.py @@ -365,6 +365,33 @@ async def get_the_log_file(log_file: str, search_backups: bool = False): return JSONResponse(content={'Response': 'Error - You must select a log file.'}, status_code=404, media_type="application/json") +@APP.get("/get_run_properties", dependencies=[Depends(JWTBearer(security))], status_code=200, response_model=None) +async def get_the_run_properties(instance_id: int, uid: str): + """ + Gets the run properties for the run specified. + + """ + # init the returned html status code + status_code = 200 + + try: + # try to make the call for records + ret_val = db_info.get_run_props(instance_id, uid) + + except Exception: + # return a failure message + ret_val = f'Exception detected trying to get the run properties for {instance_id}-{uid}.' + + # 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") + + @APP.get("/get_run_list", dependencies=[Depends(JWTBearer(security))], status_code=200, response_model=None) async def get_the_run_list(): """