Skip to content

Commit

Permalink
Merge pull request #949 from isb-cgc/isb-cgc-prod-sp
Browse files Browse the repository at this point in the history
-> Patch to fix production until Solr is ready for prime time
  • Loading branch information
s-paquette authored Dec 11, 2019
2 parents 4797aeb + 3be4fbd commit 166e999
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions cohorts/metadata_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,45 +254,21 @@ def fetch_build_data_attr(build, type=None):
'values': {}
}

if type == 'dicom':
if type == 'dicom':
attr_facet = {}
attr_facet[attr] = ""
facets = build_solr_facets(attr_facet)

# We fetch the DICOM range from Solr
result = query_solr_and_format_result({
"collection": "tcia_images",
"query_string": "*:*",
"facets": facets,
"limit": 0,
"counts_only": True
})

for val in result['facets'][attr]:
if val not in METADATA_DATA_ATTR[build][attr]['values']:
METADATA_DATA_ATTR[build][attr]['values'][val] = {
'displ_value': val,
'value': re.sub(r"[^A-Za-z0-9_\-]","",re.sub(r"\s+","-", val)),
'name': val
}
query = """
SELECT DISTINCT {attr}
FROM {data_table};
""".format(attr=attr,data_table=data_table)

else:
query = """
SELECT DISTINCT {attr}
FROM {data_table};
""".format(attr=attr,data_table=data_table)

cursor.execute(query)

for row in cursor.fetchall():
val = "None" if not row[0] else row[0]
if val not in METADATA_DATA_ATTR[build][attr]['values']:
METADATA_DATA_ATTR[build][attr]['values'][val] = {
'displ_value': val,
'value': re.sub(r"[^A-Za-z0-9_\-]","",re.sub(r"\s+","-", val)),
'name': val
}
cursor.execute(query)

for row in cursor.fetchall():
val = "None" if not row[0] else row[0]
if val not in METADATA_DATA_ATTR[build][attr]['values']:
METADATA_DATA_ATTR[build][attr]['values'][val] = {
'displ_value': val,
'value': re.sub(r"[^A-Za-z0-9_\-]","",re.sub(r"\s+","-", val)),
'name': val
}

if 'None' not in METADATA_DATA_ATTR[build][attr]['values']:
METADATA_DATA_ATTR[build][attr]['values']['None'] = {
Expand Down

0 comments on commit 166e999

Please sign in to comment.