Skip to content

Commit 6789418

Browse files
authored
Merge pull request #417 from ImagingDataCommons/idc-prod-sp
Release 47
2 parents fd13a22 + ab97549 commit 6789418

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

cohorts/views/views_api_v1.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
@require_http_methods(["POST"])
5454
def save_cohort_api(request):
5555
if debug: logger.debug('Called '+sys._getframe().f_code.co_name)
56-
57-
print(request.GET.get('email', ''))
5856
try:
5957
body = json.loads(request.body.decode('utf-8'))
6058
user = User.objects.get(email=request.GET.get('email', ''))
@@ -107,11 +105,6 @@ def cohort_manifest_api(request, cohort_id=0):
107105
}
108106
return JsonResponse(manifest_info)
109107

110-
# messages.error()
111-
# messages.error(request, 'Cohort requested does not exist.')
112-
# return redirect('/user_landing')
113-
114-
print(request.GET.get('email', ''))
115108
try:
116109
cohort = Cohort.objects.get(id=cohort_id)
117110
except ObjectDoesNotExist as e:
@@ -199,11 +192,6 @@ def cohort_query_api(request, cohort_id=0):
199192
}
200193
return JsonResponse(manifest_info)
201194

202-
# if cohort_id == 0:
203-
# messages.error(request, 'Cohort requested does not exist.')
204-
# return redirect('/user_landing')
205-
206-
# print(request.GET.get('email', ''))
207195
try:
208196
cohort = Cohort.objects.get(id=cohort_id)
209197
except ObjectDoesNotExist as e:
@@ -283,12 +271,7 @@ def cohort_preview_query_api(request):
283271
@require_http_methods(["GET"])
284272
def cohort_list_api(request):
285273
if debug: logger.debug('Called ' + sys._getframe().f_code.co_name)
286-
287-
288-
print(request.GET.get('email', ''))
289274
try:
290-
# response = cohorts_list(request)
291-
292275
user = User.objects.get(email=request.GET.get('email', ''))
293276
cohortList = []
294277

@@ -334,7 +317,6 @@ def cohort_list_api(request):
334317
def delete_cohort_api(request):
335318
if debug: logger.debug('Called {}'.format(sys._getframe().f_code.co_name))
336319
cohort_info = []
337-
print(request.GET.get('email', ''))
338320
try:
339321
user = User.objects.get(email=request.GET.get('email', ''))
340322

idc_collections/collex_metadata_utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,11 @@ def create_query_set(solr_query, sources, source, all_ui_attrs, image_source, Da
11001100
query_set.append(solr_query['queries'][attr])
11011101
else:
11021102
attStr = solr_query['queries'][attr].replace('"', '\\"')
1103+
# certain attributes values include quotes, ie Manufacturer = \"GE Healthcare\" which leads to 'subqueries'
1104+
# in filter strings with nested quotes, ie,
1105+
# _query_:"{!join to=StudyInstanceUID from=StudyInstanceUID}(+Manufacturer:(""GE Healthcare""))"))
1106+
# in this case extra backslashes are needed around the inner quotes
1107+
attStr = attStr.replace('\\\\"', '\\\\\\"')
11031108
attStr = '(_query_:"{!join to=' + default_join_field + ' from=' + default_join_field + '}' + attStr + '")'
11041109
query_set.append(attStr)
11051110
# If it's in another source for this program, we need to join on that source
@@ -1274,7 +1279,7 @@ def create_cart_query_string(query_list, partitions, join_with_child):
12741279
"parentid": "PatientID",
12751280
"id": "StudyInstanceUID",
12761281
"fields": ["collection_id", "PatientID", "StudyInstanceUID", 'StudyDescription', 'Modality', 'StudyDate',
1277-
'access', 'crdc_series_uuid', 'gcs_bucket', 'aws_bucket'],
1282+
'access', 'crdc_series_uuid', 'gcs_bucket', 'aws_bucket', 'instance_size', 'source_DOI'],
12781283
"facetfields": {
12791284
"SeriesInstanceUID": "unique_series"
12801285
},
@@ -1308,7 +1313,7 @@ def create_cart_query_string(query_list, partitions, join_with_child):
13081313
"id": "SeriesInstanceUID",
13091314
"fields": [
13101315
"collection_id", "PatientID", "StudyInstanceUID", 'SeriesInstanceUID', 'SeriesNumber', 'SeriesDescription',
1311-
'aws_bucket', 'gcs_bucket', 'Modality', 'BodyPartExamined', 'access', 'crdc_series_uuid', 'SOPInstanceUID'
1316+
'aws_bucket', 'gcs_bucket', 'Modality', 'BodyPartExamined', 'access', 'crdc_series_uuid', 'instance_size', 'source_DOI'
13121317
],
13131318
"facets": {
13141319
"per_id": {
@@ -1700,8 +1705,12 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,
17001705
with_filter = False
17011706
if (cart_query_str_all is not None) and (len(cart_query_str_all) > 0):
17021707
with_cart = True
1708+
1709+
# ok this condition assumes every collection_id sent is valid. Correct for normal workflow from webapp
17031710
if (tabletype == "collections"):
17041711
sorted_ids = current_filters["collection_id"]
1712+
#also needed
1713+
num_found=len(sorted_ids)
17051714
elif ("facetfields" in table_data) and (sortarg in table_data["facetfields"]):
17061715
# when sorting by a 'facet' field (# of cases, # of studies etc.), we need to find the set of ids selected from
17071716
# this field by the limit, offset params in a preliminary solr call, then add that set as a filter to limit the
@@ -2286,7 +2295,7 @@ def get_cart_data_serieslvl(filtergrp_list, partitions, field_list, limit, offse
22862295
solr_query = build_solr_query(
22872296
copy.deepcopy(filtergrp),
22882297
with_tags_for_ex=False,
2289-
search_child_records_by=None
2298+
search_child_records_by=None, solr_default_op='AND'
22902299
)
22912300
query_set_for_filt = create_query_set(solr_query, aux_sources, image_source, all_ui_attrs, image_source,
22922301
DataSetType, default_join_field='StudyInstanceUID')

solr_helpers/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'obese': '[30 TO *]'
2626
}
2727

28+
2829
# Combined query and result formatter method
2930
# optionally will normalize facet counting so the response structure is the same for facets+docs and just facets
3031
def query_solr_and_format_result(query_settings, normalize_facets=True, normalize_groups=True, raw_format=False):
@@ -572,6 +573,11 @@ def build_solr_query(filters, comb_with='AND', with_tags_for_ex=False, subq_join
572573
"{!join to=%s from=%s}%s" % (search_child_records_by[attr_name], search_child_records_by[attr_name],
573574
query_str.replace("\"", "\\\"")))
574575

576+
# certain attributes values include quotes, ie Manufacturer = \"GE Healthcare\" which leads to 'subqueries'
577+
# in filter strings with nested quotes, ie,
578+
# _query_:"{!join to=StudyInstanceUID from=StudyInstanceUID}(+Manufacturer:(""GE Healthcare""))"))
579+
# in this case extra backslashes are needed around the inner quotes
580+
query_str = query_str.replace('\\\\"','\\\\\\"')
575581
full_query_str += query_str
576582

577583
if with_tags_for_ex:

0 commit comments

Comments
 (0)