merge from main again

This commit is contained in:
Kenneth Kehl
2024-02-06 12:31:32 -08:00
7 changed files with 26 additions and 20 deletions

View File

@@ -105,24 +105,23 @@ def extract_phones(job):
current_app.logger.info(f"HEADERS {first_row}")
phone_index = 0
for item in first_row:
if item.lower() == "phone number":
# Note: may contain a BOM and look like \ufeffphone number
if "phone number" in item.lower():
break
phone_index = phone_index + 1
phones = {}
job_row = 0
for row in job:
row = row.split(",")
# TODO WHY ARE WE CALCULATING PHONE INDEX IN THE LOOP?
phone_index = 0
for item in first_row:
if item.lower() == "phone number":
break
phone_index = phone_index + 1
current_app.logger.info(f"PHONE INDEX IS NOW {phone_index}")
current_app.logger.info(f"LENGTH OF ROW IS {len(row)}")
if phone_index >= len(row):
phones[job_row] = "Error: can't retrieve phone number"
current_app.logger.error("Corrupt csv file, missing columns job_id {job_id} service_id {service_id}")
current_app.logger.error(
"Corrupt csv file, missing columns or possibly a byte order mark in the file"
)
else:
my_phone = row[phone_index]
my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone)

View File

@@ -283,7 +283,8 @@ class Config(object):
"simulate-delivered-2@notifications.service.gov.uk",
"simulate-delivered-3@notifications.service.gov.uk",
)
SIMULATED_SMS_NUMBERS = ("+12028675000", "+12028675111", "+12028675222")
# 7755 is success, 7167 is failure
SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")
FREE_SMS_TIER_FRAGMENT_COUNT = 250000

View File

@@ -108,6 +108,7 @@ def _update_notification_status(
current_status=notification.status, status=status
)
notification.status = status
notification.sent_at = datetime.utcnow()
if provider_response:
notification.provider_response = provider_response
if carrier:
@@ -326,13 +327,15 @@ def _filter_query(query, filter_dict=None):
def sanitize_successful_notification_by_id(notification_id, carrier, provider_response):
update_query = """
update notifications set provider_response=:response, carrier=:carrier,
notification_status='delivered', "to"='1', normalised_to='1'
notification_status='delivered', sent_at=:sent_at, "to"='1', normalised_to='1'
where id=:notification_id
"""
input_params = {
"notification_id": notification_id,
"carrier": carrier,
"response": provider_response,
"sent_at": datetime.utcnow(),
}
db.session.execute(update_query, input_params)