Skip to content

Commit

Permalink
MRG: Merge pull request #11 from aerosense-ai/fix/fix-software-config…
Browse files Browse the repository at this point in the history
…uration-uniqueness-check

Use correct column name when checking configuration uniqueness
  • Loading branch information
cortadocodes authored Dec 13, 2021
2 parents 9ffb555 + 40d1f73 commit a25c0f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions cloud_functions/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,14 @@ def add_configuration(self, configuration):
# Installation data is stored in a separate column, so pop it before the next step.
installation_data = configuration.pop("installation_data")

configuration_json = json.dumps(configuration)
configuration_hash = blake3(configuration_json.encode()).hexdigest()
software_configuration_json = json.dumps(configuration)
software_configuration_hash = blake3(software_configuration_json.encode()).hexdigest()

configurations = list(
self.client.query(f"SELECT id FROM `{table_name}` WHERE `hash`='{configuration_hash}' LIMIT 1").result()
self.client.query(
f"SELECT id FROM `{table_name}` WHERE `software_configuration_hash`='{software_configuration_hash}' "
f"LIMIT 1"
).result()
)

if len(configurations) > 0:
Expand All @@ -222,8 +225,8 @@ def add_configuration(self, configuration):
rows=[
{
"id": configuration_id,
"software_configuration": configuration_json,
"software_configuration_hash": configuration_hash,
"software_configuration": software_configuration_json,
"software_configuration_hash": software_configuration_hash,
"installation_data": installation_data_json,
"installation_data_hash": installation_data_hash,
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="data_gateway",
version="0.7.4",
version="0.7.5",
install_requires=[
"click>=7.1.2",
"pyserial==3.5",
Expand Down

0 comments on commit a25c0f6

Please sign in to comment.