Skip to content

Commit

Permalink
fix indicator table update in h3 data for vector files
Browse files Browse the repository at this point in the history
  • Loading branch information
elpamart committed Oct 4, 2023
1 parent 874f320 commit c277d58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions data/h3_data_importer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_metadata(table: str) -> dict:
return metadata


def link_to_indicator_table(connection: connection, indicator_code: str, h3_column_name: str):
def link_to_indicator_table(connection: connection, indicator_code: str, h3_table_name: str, h3_column_name: str):
"""Gets indicatorID and links it to the h3table corresponding entry"""
with connection:
with connection.cursor() as cursor:
Expand All @@ -136,9 +136,9 @@ def link_to_indicator_table(connection: connection, indicator_code: str, h3_colu
if indicator_id:
cursor.execute(
f"""update "h3_data" set "indicatorId" = '{indicator_id}'
where "h3columnName" = '{h3_column_name}'"""
where "h3tableName" = '{h3_table_name}' and "h3columnName" = '{h3_column_name}'"""
)
log.info(f"Updated indicatorId '{indicator_id}' in h3_data for {h3_column_name}")
log.info(f"Updated indicatorId '{indicator_id}' in h3_data for {h3_table_name}.{h3_column_name}")
else:
log.error(f"Indicator with name code {indicator_code} does not exist")

Expand Down
2 changes: 1 addition & 1 deletion data/h3_data_importer/vector_folder_to_h3_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def main(
return # gracefully exit without exception

if indicator_code: # if given, consider layer as indicator update h3_table
link_to_indicator_table(conn, indicator_code, column)
link_to_indicator_table(conn, indicator_code, table, column)

postgres_thread_pool.putconn(conn, close=True)

Expand Down

0 comments on commit c277d58

Please sign in to comment.