Skip to content

Commit

Permalink
omit check for existing temporary records
Browse files Browse the repository at this point in the history
  • Loading branch information
frankhereford committed May 6, 2024
1 parent 64ba91e commit 4632c05
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
15 changes: 0 additions & 15 deletions atd-etl/cris_import/cris_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,21 +669,6 @@ def align_records(map_state):
print("Changed column count: " + str(len(changed_columns['changed_columns'])))
print("Changed Columns:" + str(changed_columns["changed_columns"]))

try:
# this seemingly violates the principal of treating each record source equally, however, this is
# really only a reflection that we create incomplete temporary records consisting only of a crash record
# and not holding place entities for units, persons, etc.
if table == "crash" and util.has_existing_temporary_record(pg, source["case_id"]):
print("\b🛎: " + str(source["crash_id"]) + " has existing temporary record")
time.sleep(5)
util.remove_existing_temporary_record(pg, source["case_id"])
except:
# Trap the case of a missing case_id key error in the RealDictRow object.
# A RealDictRow, returned by the psycopg2 cursor, is a dictionary-like object,
# but lacks has_key() and other methods.
print("Skipping checking on existing temporary record for " + str(source["crash_id"]))
pass

# build an comma delimited list of changed columns
all_changed_columns = ", ".join(important_changed_columns["changed_columns"] + changed_columns["changed_columns"])

Expand Down
27 changes: 0 additions & 27 deletions atd-etl/cris_import/lib/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,33 +226,6 @@ def is_change_existing(pg, record_type, record_id):
return False


def has_existing_temporary_record(pg, case_id):
sql = f"""
select count(*) as exists
from atd_txdot_crashes
where crash_id < 10000
and case_id = '{case_id}'
"""
cursor = pg.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cursor.execute(sql)
change_request_exists = cursor.fetchone()
if change_request_exists["exists"] > 0:
return True
else:
return False


def remove_existing_temporary_record(pg, case_id):
sql = f"""
delete from atd_txdot_crashes
where crash_id < 10000
and case_id = '{case_id}'
"""
cursor = pg.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cursor.execute(sql)
return True


def try_statement(pg, output_map, table, public_key_sql, sql, dry_run):
if dry_run:
print("Dry run; skipping")
Expand Down

0 comments on commit 4632c05

Please sign in to comment.