From c33a92cdeb0db835d48618f693c60683d3cd50ab Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2024 10:50:53 -0800 Subject: [PATCH] fix unopened report rank 1 sorting run unopened report with async call --- request-management-api/request_api/resources/request.py | 5 ++--- .../request_api/services/unopenedreportservice.py | 4 ++-- request-management-api/requirements.txt | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/request-management-api/request_api/resources/request.py b/request-management-api/request_api/resources/request.py index 335a4fac8..8248453e2 100644 --- a/request-management-api/request_api/resources/request.py +++ b/request-management-api/request_api/resources/request.py @@ -338,8 +338,7 @@ class FOIRawRequestReport(Resource): @auth.require def post(): try: - result = unopenedreportservice().generateunopenedreport() - # responsecode = 200 if result.success == True else 500 - return {'status': True, 'message': result} , 200 + asyncio.ensure_future(unopenedreportservice().generateunopenedreport()) + return {'status': True, 'message': 'async report function called'} , 200 except BusinessException as exception: return {'status': exception.status_code, 'message':exception.message}, 500 \ No newline at end of file diff --git a/request-management-api/request_api/services/unopenedreportservice.py b/request-management-api/request_api/services/unopenedreportservice.py index 2fbaddad7..2d1f0bdf8 100644 --- a/request-management-api/request_api/services/unopenedreportservice.py +++ b/request-management-api/request_api/services/unopenedreportservice.py @@ -21,7 +21,7 @@ class unopenedreportservice: reportemail = getenv('UNOPENED_REPORT_EMAIL_RECIPIENT') - def generateunopenedreport(self): + async def generateunopenedreport(self): startdate = date.today() - timedelta(days=int(self.dayscutoff)) enddate = date.today() - timedelta(days=int(self.waitdays)) requests = FOIRawRequest.getunopenedunactionedrequests(str(startdate), str(enddate)) @@ -54,7 +54,7 @@ def generateunopenedreport(self): } for m in potentialmatches]} UnopenedReport.insert(alert) alerts.append({"request": request, "rank": 2, "potentialmatches": alert.potentialmatches}) - alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': 0})['highscore']) + alerts.sort(key=lambda a : a.get('potentialmatches', {'highscore': -1})['highscore']) senderservice().send( subject="Intake Unopened Request Report: " + str(date.today()), content=self.generateemailhtml(alerts), diff --git a/request-management-api/requirements.txt b/request-management-api/requirements.txt index ddc56c845..6debf8925 100644 --- a/request-management-api/requirements.txt +++ b/request-management-api/requirements.txt @@ -52,7 +52,7 @@ python-dotenv==0.16.0 python-editor==1.0.4 python-jose==3.2.0 pytz==2021.1 -requests==2.25.1 +requests==2.31.0 rsa==4.7.2 sentry-sdk==1.0.0 six==1.15.0 @@ -66,9 +66,9 @@ maya==0.6.1 pyjwt==2.1.0 aws-requests-auth==0.4.3 holidays==0.12 -Flask-SocketIO==5.1.0 +Flask-SocketIO==5.3.6 Flask-Login==0.5.0 -eventlet==0.33.3 +eventlet==0.35.2 uritemplate.py==3.0.2 urllib3==1.26.15 ndg-httpsclient