Skip to content
Snippets Groups Projects

WS-2355 Calibration wrester telescope

Merged Daniel Nemergut requested to merge ws2355-calibration_curation into 2.8.4-DEVELOPMENT
All threads resolved!
@@ -366,7+366,7 @@
LEFT JOIN execution_blocks eb ON sp.science_product_locator = eb.science_product_locator
LEFT JOIN images im ON sp.science_product_locator = im.science_product_locator
WHERE sp.science_product_locator = %(spl)s;
+2
"""
make_json = {}
try:
cursor = self.conn.cursor()
@@ -388,7+388,7 @@
cursor.execute(query, {"spl": spl})
data = cursor.fetchall()
if data:
product_type = str(data[0][0]).lower().replace(" ", "_")
if product_type != 'calibration':
telescope = data[0][1]
else:
# Need to query on the eb / alma_ous_id to get a telescope for calibrations
scope_query = """
SELECT telescope
FROM execution_blocks
JOIN calibrations c_eb ON execution_blocks.execution_block_id = c_eb.execution_block_id
WHERE c_eb.science_product_locator = %(spl)s
UNION
SELECT telescope
FROM execution_blocks
JOIN calibrations c_ous ON execution_blocks.alma_ous_id = c_ous.alma_ous_id
WHERE c_ous.science_product_locator = %(spl)s
"""
cursor.execute(scope_query, {"spl": spl})
scope_data = cursor.fetchall()
if scope_data:
telescope = scope_data[0][0]
else:
self.logger.error(f"ERROR: Failed to determine telescope from calibration's EB, got {data}")
return make_json
make_json = {
"product_type": str(data[0][0]).lower().replace(" ", "_"),
"telescope": data[0][1],
"product_type": product_type,
"telescope": telescope,
"projectCode": data[0][2],
}
Loading