Skip to content

Commit 4bd7bb9

Browse files
author
George
committed
fix bug where opening/closing or refiltering tables led to incorrect stats repoted when a series level cart selection was made; fix bug where reopening a series table led to a server error when only series level cart selections were made
1 parent e11dda9 commit 4bd7bb9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

idc_collections/collex_metadata_utils.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,13 @@ def create_cart_query_string(query_list, partitions, join_with_child):
12441244
}
12451245
cart_facets_serieslvl = {"series_in_cart": {"type": "terms", "field": "collection_d", "limit":500,
12461246
"facet": { "unique_series_cart": "unique(SeriesInstanceUID)"},
1247-
}}
1247+
1248+
},
1249+
"series_in_filter_and_cart": {"type": "terms", "field": "collection_id", "limit": 500,
1250+
"facet": {
1251+
"unique_series_filter_and_cart": "unique(SeriesInstanceUID)"},
1252+
"domain": {"filter": ""}}
1253+
}
12481254

12491255

12501256
upstream_cart_facets = {
@@ -1391,7 +1397,7 @@ def generate_solr_cart_and_filter_strings(current_filters,filtergrp_list, partit
13911397
cart_query_str_studylvl = None
13921398

13931399
if (len(partitions_series_lvl) > 0):
1394-
cart_query_str_serieslvl = create_cart_query_string(query_list, partitions_series_lvl, False)
1400+
cart_query_str_serieslvl = create_cart_query_string(query_list, partitions_series_lvl, True)
13951401
else:
13961402
cart_query_str_serieslvl = None
13971403

@@ -1667,7 +1673,7 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,f
16671673
if tabletype in ["cases","series","studies"]:
16681674
collstr= list(attrRowNumMp["collections"].keys())
16691675
colrngfilt = '(+collection_id:('+ ' OR '.join(['"'+x+'"' for x in collstr ]) +'))'
1670-
colrngQ='('+colrngfilt+')('+cart_query_str_studylvl+')'
1676+
colrngQ='('+colrngfilt+')('+cart_query_str_all+')'
16711677
custom_facets["upstream_collection_cart"]=copy.deepcopy(upstream_cart_facets["upstream_collection_cart"])
16721678
custom_facets["upstream_collection_cart"]["domain"]["filter"]=colrngQ
16731679

@@ -1677,7 +1683,7 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,f
16771683
if tabletype in ["series","studies"]:
16781684
casestr= list(attrRowNumMp["cases"].keys())
16791685
caserngfilt = '(+PatientID:('+ ' OR '.join(['"'+x+'"' for x in casestr ]) +'))'
1680-
caserngQ = '(' + caserngfilt + ')(' + cart_query_str_studylvl + ')'
1686+
caserngQ = '(' + caserngfilt + ')(' + cart_query_str_all + ')'
16811687
custom_facets["upstream_case_cart"] = copy.deepcopy(upstream_cart_facets["upstream_case_cart"])
16821688
custom_facets["upstream_case_cart"]["domain"]["filter"] = caserngQ
16831689
custom_facets["upstream_case_filter_cart"] = copy.deepcopy(upstream_cart_facets["upstream_case_filter_cart"])
@@ -1687,7 +1693,7 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,f
16871693
if tabletype in ["series"]:
16881694
studystr= list(attrRowNumMp["studies"].keys())
16891695
studyrngfilt = '(+StudyInstanceUID:('+ ' OR '.join(['"'+x+'"' for x in studystr ]) +'))'
1690-
studyrngQ = '(' + studyrngfilt + ')(' + cart_query_str_studylvl + ')'
1696+
studyrngQ = '(' + studyrngfilt + ')(' + cart_query_str_all + ')'
16911697
custom_facets["upstream_study_cart"] = copy.deepcopy(upstream_cart_facets["upstream_study_cart"])
16921698
custom_facets["upstream_study_cart"]["domain"]["filter"] = studyrngQ
16931699
custom_facets["upstream_study_filter_cart"] = copy.deepcopy(upstream_cart_facets["upstream_study_filter_cart"])
@@ -1736,8 +1742,13 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,f
17361742
if not (cart_query_str_serieslvl==None) and (len(cart_query_str_serieslvl)>0):
17371743

17381744
custom_facets = cart_facets_serieslvl
1739-
custom_facets["series_in_cart"]["domain"]={"filter": cart_query_str_serieslvl}
1740-
custom_facets["series_in_cart"]["field"]=id
1745+
custom_facets["series_in_filter_and_cart"]["domain"]={"filter": cart_query_str_serieslvl}
1746+
custom_facets["series_in_filter_and_cart"]["field"]=id
1747+
1748+
in_cart_domain_serieslvl = {"filter": '(+' + cart_query_str_serieslvl + ')',"excludeTags": "f1"} if with_filter else {"filter": cart_query_str_serieslvl}
1749+
custom_facets["series_in_cart"]["field"] = id
1750+
custom_facets["series_in_cart"]["domain"] = in_cart_domain_serieslvl
1751+
17411752

17421753
if tabletype in ["cases","studies","series"]:
17431754
colrngQ = '(' + colrngfilt + ')(' + cart_query_str_serieslvl + ')'
@@ -1767,6 +1778,8 @@ def get_table_data_with_cart_data(tabletype, sortarg, sortdir, current_filters,f
17671778
custom_facets["upstream_study_filter_cart"] = copy.deepcopy(upstream_cart_facets["upstream_study_filter_cart"])
17681779
custom_facets["upstream_study_filter_cart"]["domain"]["filter"] = studyrngQ+no_tble_item_filt_str
17691780

1781+
1782+
17701783
solr_facet_result_serieslvl = query_solr(
17711784
collection=image_source_series.name, fields=field_list, query_string=None, fqs=fqset[:],
17721785
facets=custom_facets, sort=sortStr, counts_only=True, collapse_on=None, offset=0, limit=limit,

0 commit comments

Comments
 (0)