From b33730afa68bb62fbfbf28067d6f603516a5fec5 Mon Sep 17 00:00:00 2001 From: Steve Astels Date: Wed, 6 Mar 2024 14:57:03 -0500 Subject: [PATCH] Add logging and tweak recipient_csv use (#2132) --- app/job/rest.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/job/rest.py b/app/job/rest.py index a5e6c0e2ae..00b55e4cde 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -173,27 +173,27 @@ def create_job(service_id): if template.template_type == SMS_TYPE: # calculate the number of simulated recipients - numberOfSimulated = sum( - simulated_recipient(i["phone_number"].data, template.template_type) for i in list(recipient_csv.get_rows()) - ) - mixedRecipients = numberOfSimulated > 0 and numberOfSimulated != len(list(recipient_csv.get_rows())) + numberOfSimulated = sum(simulated_recipient(i["phone_number"].data, template.template_type) for i in recipient_csv.rows) + mixedRecipients = numberOfSimulated > 0 and numberOfSimulated != len(recipient_csv) # if they have specified testing and NON-testing recipients, raise an error if mixedRecipients: raise InvalidRequest(message="Bulk sending to testing and non-testing numbers is not supported", status_code=400) - is_test_notification = len(list(recipient_csv.get_rows())) == numberOfSimulated + is_test_notification = len(recipient_csv) == numberOfSimulated if not is_test_notification: check_sms_daily_limit(service, len(recipient_csv)) increment_sms_daily_count_send_warnings_if_needed(service, len(recipient_csv)) elif template.template_type == EMAIL_TYPE: - check_email_daily_limit(service, len(list(recipient_csv.get_rows()))) + check_email_daily_limit(service, len(recipient_csv)) + current_app.logger.info(" TEMP LOGGING 6a: done check_email_daily_limit") + scheduled_for = datetime.fromisoformat(data.get("scheduled_for")) if data.get("scheduled_for") else None if scheduled_for is None or not scheduled_for.date() > datetime.today().date(): - increment_email_daily_count_send_warnings_if_needed(service, len(list(recipient_csv.get_rows()))) + increment_email_daily_count_send_warnings_if_needed(service, len(recipient_csv)) current_app.logger.info(" TEMP LOGGING 6: done checking limits") data.update({"template_version": template.version})