def get_job_latest_result_set( *, db_session: Session = Depends(deps.db_session), result_set_crud: CRUDResultSet = Depends(deps.result_set_crud), job_name: str, ) -> Any: """Get the latest result set of a Job""" try: return result_set_crud.get_latest_for_active_job(db_session, job_name=job_name) except ResultSetNotFound as ex: raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=str(ex)) from ex
def get_job_latest_result_set( *, db_session: Session = Depends(deps.db_session), result_set_crud: CRUDResultSet = Depends(deps.result_set_crud), job_name: str, result_format: schemas.ResultSetFormat = schemas.ResultSetFormat.json, ) -> Any: """Get the latest result set of a Job""" try: result_set = result_set_crud.get_latest_for_active_job( db_session, job_name=job_name) except ResultSetNotFound as ex: raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=str(ex)) from ex if result_format == schemas.ResultSetFormat.csv: return Response(content=result_set.to_api_schema().to_csv(), media_type="text/csv") return result_set
def get_job_latest_result_set( *, db_session: Session = Depends(deps.db_session), result_set_crud: CRUDResultSet = Depends(deps.result_set_crud), job_name: str, result_format: schemas.ResultSetFormat = schemas.ResultSetFormat.json, response: Response, if_none_match: Optional[str] = Header(None), ) -> Any: """Get the latest result set of a Job""" try: result_set = result_set_crud.get_latest_for_active_job(db_session, job_name=job_name) response.headers["Cache-Control"] = "public, must-revalidate, proxy-revalidate, max-age=30" etag = base64.b64encode(str(result_set.created).encode()).decode() response.headers["ETag"] = etag if etag == if_none_match: return Response(status_code=HTTP_304_NOT_MODIFIED) except ResultSetNotFound as ex: raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=str(ex)) from ex if result_format == schemas.ResultSetFormat.csv: return Response(content=result_set.to_api_schema().to_csv(), media_type="text/csv") return result_set