Skip to content

Commit d0a21e2

Browse files
committed
Removed redundant query for SearchFilterValuesDataGetter
1 parent 9539ff9 commit d0a21e2

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private static void addFilterValueLabels(Map<String, SearchFilter> filterConfigu
314314
for (SearchFilter filter : filterConfigurationsByField.values()) {
315315
if (filter.isLocalizationRequired()) {
316316
for (FilterValue value : filter.getValues().values()) {
317-
if (StringUtils.isBlank(value.getName())) {
317+
if (StringUtils.isBlank(value.getName()) && !value.getId().contains(" ")) {
318318
String label = SearchFiltering.getUriLabel(value.getId(), vreq);
319319
if (!StringUtils.isBlank(label)) {
320320
value.setName(label);

api/src/main/java/edu/cornell/mannlib/vitro/webapp/utils/dataGetter/SearchFilterValuesDataGetter.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ public SearchFilterValuesDataGetter(VitroRequest vreq, Model displayModel, Strin
4848
public Map<String, Object> getData(Map<String, Object> pageData) {
4949
Map<String, Object> responseMap = new HashMap<>();
5050
responseMap.putAll(vreq.getParameterMap());
51-
Map<String, List<String>> requestFilters = new HashMap<>();
52-
requestFilters.put(searchFilter, new ArrayList<String>(Arrays.asList(ANY_VALUE)));
53-
Map<String, Object> defaultSearchResults = PagedSearchController.process(vreq, requestFilters).getMap();
54-
responseMap.put("filterGenericInfo", defaultSearchResults);
55-
requestFilters = SearchFiltering.getRequestFilters(vreq);
51+
Map<String, List<String>> requestFilters = SearchFiltering.getRequestFilters(vreq);
5652
if (!isValidFilterValueProvided(requestFilters)) {
5753
requestFilters.put(searchFilter, new ArrayList<String>(Arrays.asList(ANY_VALUE)));
5854
}

webapp/src/main/webapp/templates/freemarker/body/menupage/browseSearchFilterValues.ftl

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<#import "search-lib.ftl" as sl>
33

44
<#-- <#assign additionalFilters = ["type"]> -->
5-
<#if filterGenericInfo.filters[searchFilter]??>
5+
<#if filters[searchFilter]??>
66

77
<script>
88
let searchFormId = "filter-form";
@@ -34,7 +34,7 @@
3434
</#list>
3535
<@filterTab searchFilter />
3636
<#else>
37-
<@filterFacets filterGenericInfo.filters[searchFilter] />
37+
<@filterFacets filters[searchFilter] />
3838
</#if>
3939
</ul>
4040
<@alphabeticalIndexLinks />
@@ -63,10 +63,10 @@
6363
</#if>
6464

6565
<#macro filterTab filterId>
66-
<#if filterGenericInfo.filters[filterId]?? >
67-
<#assign filter = filterGenericInfo.filters[filterId] >
66+
<#if filters[filterId]?? >
67+
<#assign filter = filters[filterId] >
6868
<#if filter.display >
69-
<#assign filterValues><@getValues filter filterId /></#assign>
69+
<#assign filterValues><@getValues filter /></#assign>
7070
<#if filterValues?has_content>
7171
<li class="filter-tab">
7272
<a href="#">${filter.name?html}</a>
@@ -77,18 +77,18 @@
7777
</#if>
7878
</#macro>
7979

80-
<#macro getValues filter filterId>
80+
<#macro getValues filter>
8181
<#if filter.type == "RangeFilter">
8282
<ul class="facet-values">
83-
<#if filters[filterId]?? && filters[filterId].selected>
83+
<#if filter.selected>
8484
<li class="li-selected">
8585
<a href="#" class="selected">
86-
<@sl.userSelectedInput filters[filterId] "filter-form" />
86+
<@sl.userSelectedInput filter "filter-form" />
8787
</a>
8888
</li>
8989
</#if>
90-
<li <#if filter.selected || (filters[filterId]?? && filters[filterId].selected)> class="li-selected" </#if>>
91-
<@sl.rangeFilter filters[filterId] 'filter-form'/>
90+
<li <#if filter.selected> class="li-selected" </#if>>
91+
<@sl.rangeFilter filter 'filter-form'/>
9292
</li>
9393
</ul>
9494
<#else>
@@ -120,17 +120,19 @@
120120
<#continue>
121121
</#if>
122122
<#assign valueLabel = value.name >
123-
<#assign resultsCount = getCurrentCount(f value) >
123+
<#assign resultsCount = value.count >
124124
<#if !(valueLabel?has_content)>
125125
<#assign valueLabel = value.id >
126126
</#if>
127127
<#if value.selected>
128-
<li id="${value.id?html}" class="li-selected">
129-
<a href="#" class="selected">
130-
<@sl.getInput f value sl.getValueID(f.id, idCounter) idCounter 'filter-form' />
131-
<@sl.getSelectedLabel sl.getValueID(f.id, idCounter)?html value f resultsCount />
132-
</a>
133-
</li>
128+
<#if value.id != "[* TO *]">
129+
<li id="${value.id?html}" class="li-selected">
130+
<a href="#" class="selected">
131+
<@sl.getInput f value sl.getValueID(f.id, idCounter) idCounter 'filter-form' />
132+
<@sl.getSelectedLabel sl.getValueID(f.id, idCounter)?html value f resultsCount />
133+
</a>
134+
</li>
135+
</#if>
134136
<#else>
135137
<#if resultsCount != 0>
136138
<li id="${value.id?html}">
@@ -145,27 +147,14 @@
145147
</#list>
146148
</#macro>
147149

148-
<#function getCurrentCount f v>
149-
<#if filters[f.id]??>
150-
<#assign filter = filters[f.id]>
151-
<#if filter.values[v.id]??>
152-
<#return filter.values[v.id].count >
153-
<#else>
154-
<#return 0 />
155-
</#if>
156-
<#else>
157-
<#return 0 />
158-
</#if>
159-
</#function>
160-
161150
<#macro alphabeticalIndexLinks>
162151
<#if languageAware >
163152
<#assign indexFilterName = "label_regex">
164153
<#else>
165154
<#assign indexFilterName = "raw_label_regex">
166155
</#if>
167-
<#if filterGenericInfo.filters[indexFilterName]??>
168-
<#assign indexFilter = filterGenericInfo.filters[indexFilterName]>
156+
<#if filters[indexFilterName]??>
157+
<#assign indexFilter = filters[indexFilterName]>
169158
<nav id="alpha-browse-container" role="navigation">
170159
<ul id="alpha-browse-individuals">
171160
<li>

0 commit comments

Comments
 (0)