fix personalization_bug for one-offs

This commit is contained in:
Kenneth Kehl
2024-10-01 10:47:47 -07:00
parent 216528d589
commit c2ed8f1686
2 changed files with 34 additions and 27 deletions

View File

@@ -366,7 +366,6 @@ def extract_phones(job):
def extract_personalisation(job):
job = job[0].split("\r\n")
first_row = job[0]
job.pop(0)
@@ -398,11 +397,8 @@ def get_phone_number_from_s3(service_id, job_id, job_row_number):
)
return "Unavailable"
# If we look in the job_cache for the quick lookup dictionary of phones for a given job
# and that dictionary is not there, create it
if job_cache.get(f"{job_id}_phones") is None:
phones = extract_phones(job)
set_job_cache(job_cache, f"{job_id}_phones", phones)
phones = extract_phones(job)
set_job_cache(job_cache, f"{job_id}_phones", phones)
# If we can find the quick dictionary, use it
phone_to_return = phones[job_row_number]
@@ -420,9 +416,6 @@ def get_personalisation_from_s3(service_id, job_id, job_row_number):
# At the same time we don't want to store it in redis or the db
# So this is a little recycling mechanism to reduce the number of downloads.
job = job_cache.get(job_id)
if job is None:
job = get_job_from_s3(service_id, job_id)
set_job_cache(job_cache, job_id, job)
# If the job is None after our attempt to retrieve it from s3, it
# probably means the job is old and has been deleted from s3, in
@@ -435,12 +428,7 @@ def get_personalisation_from_s3(service_id, job_id, job_row_number):
)
return {}
# If we look in the job_cache for the quick lookup dictionary of personalisations for a given job
# and that dictionary is not there, create it
if job_cache.get(f"{job_id}_personalisation") is None:
set_job_cache(
job_cache, f"{job_id}_personalisation", extract_personalisation(job)
)
set_job_cache(job_cache, f"{job_id}_personalisation", extract_personalisation(job))
# If we can find the quick dictionary, use it
if job_cache.get(f"{job_id}_personalisation") is not None: