Skip to content

Commit

Permalink
Exclude boolean parameters from feed title
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasl committed Jul 12, 2023
1 parent 79561c3 commit 518e445
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions rest/src/main/groovy/whelk/rest/api/SearchFeed.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import static whelk.JsonLd.asList
@CompileStatic
class SearchFeed {

static final String BULLET_SEP = ""

JsonLd jsonld
List<String> locales

Set<String> skipKeys = [ID_KEY, REVERSE_KEY, 'meta', 'reverseLinks'] as Set
Set<String> skipDetails = skipKeys + ([TYPE_KEY, 'commentByLang'] as Set)

String feedTitle

SearchFeed(JsonLd jsonld, List<String> locales) {
this.jsonld = jsonld
this.locales = locales
Expand Down Expand Up @@ -64,8 +64,9 @@ class SearchFeed {
String buildTitle(Map searchResults) {
var title = getByLang((Map) searchResults['titleByLang'])
def params = searchResults.search?.mapping?.findResults {
var o = toValueString(it.object, skipDetails)
return o
if (it.value !instanceof Boolean) {
return toValueString(it.value ?: it.object, skipDetails)
}
}
if (params) {
return title + ': ' + params.join(' & ')
Expand Down Expand Up @@ -107,6 +108,8 @@ class SearchFeed {
if (item instanceof Map) {
def chip = jsonld.toChip(item)
return toValueString(chip)
} else if (item == null) {
return ""
} else {
return item.toString()
}
Expand All @@ -128,7 +131,7 @@ class SearchFeed {
}
}
} else {
if (sb.size() > 0) sb.append("")
if (sb.size() > 0) sb.append(BULLET_SEP)
sb.append(o.toString())
}
}
Expand Down

0 comments on commit 518e445

Please sign in to comment.