Skip to content

Commit

Permalink
fix unopened report rank 1 sorting
Browse files Browse the repository at this point in the history
run unopened report with async call
  • Loading branch information
nkan-aot2 committed Feb 28, 2024
1 parent de019e7 commit c33a92c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions request-management-api/request_api/resources/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions request-management-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c33a92c

Please sign in to comment.