From 75f0fb039bafcebdcc39e624c5b730bdf2a5be19 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Mon, 23 Oct 2023 10:54:26 -0500 Subject: [PATCH] refactor to be less nested Signed-off-by: Isaac Milarsky --- .../facade_worker/utilitymethods.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/augur/tasks/git/util/facade_worker/facade_worker/utilitymethods.py b/augur/tasks/git/util/facade_worker/facade_worker/utilitymethods.py index 514847c4d6..aef4e59989 100644 --- a/augur/tasks/git/util/facade_worker/facade_worker/utilitymethods.py +++ b/augur/tasks/git/util/facade_worker/facade_worker/utilitymethods.py @@ -235,7 +235,7 @@ def facade_bulk_insert_commits(session,records): facade_bulk_insert_commits(session,firsthalfRecords) facade_bulk_insert_commits(session,secondhalfRecords) - elif len(records) == 1 and isinstance(e,DataError): + elif len(records) == 1 and isinstance(e,DataError) and "time zone displacement" in f"{e}": commit_record = records[0] #replace incomprehensible dates with epoch. #2021-10-11 11:57:46 -0500 @@ -244,18 +244,14 @@ def facade_bulk_insert_commits(session,records): #Check for improper utc timezone offset #UTC timezone offset should be betwen -14:00 and +14:00 - if "time zone displacement" in f"{e}": - commit_record['author_timestamp'] = placeholder_date - commit_record['committer_timestamp'] = placeholder_date - - session.execute( - s.insert(Commit), - [commit_record], - ) - session.commit() - else: - session.logger.error(f"Ran into issue when trying to insert commit: {commit_record} \n Error: {e}") - raise e + commit_record['author_timestamp'] = placeholder_date + commit_record['committer_timestamp'] = placeholder_date + + session.execute( + s.insert(Commit), + [commit_record], + ) + session.commit() else: raise e