Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run unopened report with async call #5098

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading