From 277262ed69fdf211a166b054224ab1421db2c584 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 31 Jan 2024 08:06:09 -0800 Subject: [PATCH 1/3] handle error --- app/aws/s3.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index 7e3e4585a..7789d80ed 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -120,9 +120,13 @@ def extract_phones(job): 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)}") - my_phone = row[phone_index] - my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone) - phones[job_row] = my_phone + 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}") + else: + my_phone = row[phone_index] + my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone) + phones[job_row] = my_phone job_row = job_row + 1 return phones From fa2b18d5b7b6e6f8e847385b09276d3bce6e982c Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 31 Jan 2024 08:10:48 -0800 Subject: [PATCH 2/3] fix logic --- app/aws/s3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index 7789d80ed..0419cada0 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -120,7 +120,7 @@ def extract_phones(job): 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): + 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}") else: From aecff08d7ae1169be60a59dae1f5b618f1cfc2e3 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Wed, 31 Jan 2024 08:20:12 -0800 Subject: [PATCH 3/3] remove cache hit/miss writes to log --- app/aws/s3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index 0419cada0..e1c14e1c6 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -84,7 +84,7 @@ def incr_jobs_cache_misses(): redis_store.incr(JOBS_CACHE_MISSES) hits = redis_store.get(JOBS_CACHE_HITS).decode("utf-8") misses = redis_store.get(JOBS_CACHE_MISSES).decode("utf-8") - current_app.logger.info(f"JOBS CACHE MISS hits {hits} misses {misses}") + current_app.logger.debug(f"JOBS CACHE MISS hits {hits} misses {misses}") def incr_jobs_cache_hits(): @@ -94,7 +94,7 @@ def incr_jobs_cache_hits(): redis_store.incr(JOBS_CACHE_HITS) hits = redis_store.get(JOBS_CACHE_HITS).decode("utf-8") misses = redis_store.get(JOBS_CACHE_MISSES).decode("utf-8") - current_app.logger.info(f"JOBS CACHE HIT hits {hits} misses {misses}") + current_app.logger.debug(f"JOBS CACHE HIT hits {hits} misses {misses}") def extract_phones(job):