Skip to content
Snippets Groups Projects

Made a dumb mistake and forgot to put the argument in the query

Merged Nathan Bockisch requested to merge ws-1992-add-image-wrester into 2.8.2.1-DEVELOMENT
1 unresolved thread
2 files
+ 16
13
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -392,31 +392,32 @@ class WrestWorkflowMetadata:
:return: JSON containing the product list
"""
make_json = {}
product_group_id = ""
try:
cursor = self.conn.cursor()
if self.spl[0].isdigit():
product_group_id = self.spl[0]
else:
# We were given an SPL, need to get the associated product group ID
prod_id_query = """
prod_id_query = f"""
SELECT product_group_id
FROM science_products_product_groups
WHERE science_product_locator = %(spl)s;
WHERE science_product_locator = '{self.spl[0]}';
"""
cursor.execute(prod_id_query, {"spl": self.spl[0]})
cursor.execute(prod_id_query)
data = cursor.fetchall()
if data:
product_group_id = data[0][0]
else:
self.logger.error(f"ERROR: Failed to fetch product group id from SPL, got {data[0][0]}")
self.logger.error(f"ERROR: Failed to fetch product group id from SPL, got {data}")
files_query = """
files_query = f"""
WITH product_locators AS (
SELECT sp.science_product_locator,
ap.ancillary_product_locator
FROM science_products_product_groups sp
JOIN ancillary_products ap ON sp.product_group_id = ap.product_group_id
WHERE sp.product_group_id = %(pgi)s
WHERE sp.product_group_id = '{product_group_id}'
), filegroups AS (
SELECT ap2.filegroup_id
FROM ancillary_products ap2
@@ -430,13 +431,16 @@ class WrestWorkflowMetadata:
FROM files f
JOIN filegroups fg ON f.filegroup = fg.filegroup_id
"""
cursor.execute(files_query, {"pgi": product_group_id})
data = cursor.fetchall()
if data:
# This should have all the ancillary and science product names
make_json = json.dumps({"filesList": [file] for file in data})
if product_group_id != "":
cursor.execute(files_query)
data = cursor.fetchall()
if data:
# This should have all the ancillary and science product names
make_json = json.dumps({"filesList": [file] for file in data})
else:
self.logger.error(f"ERROR: Failed to fetch products from product ID {product_group_id}")
else:
self.logger.error(f"ERROR: Failed to fetch products from product ID {product_group_id}")
self.logger.error(f"ERROR: Failed to get product group ID")
finally:
self.conn.close()
return make_json
Loading