Skip to content

Commit

Permalink
Refactor index string fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bryophyta committed Jan 16, 2023
1 parent 98caa6d commit a7309bb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion admin/app/jobs/RebuildIndexJob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ class RebuildIndexJob(contentApiClient: ContentApiClient)(implicit executionCont
contributors <- contentApiTagsEnumerator.enumerateTagType("contributor")
} yield {
val contributorsByNameOrder: Map[String, Set[Tag]] = contributors.toSet
.groupBy(tag => tagPages.alphaIndexKey(tag.lastName orElse tag.firstName getOrElse tag.webTitle))
.groupBy(tag => {

/**
* The alphaIndexKey function looks at the first alphanumeric character in the string passed to it.
* Concatenating these three strings therefore allows us to use firstName and webTitle as fallbacks
* if lastName is None or "".
* */
val indexString = tag.lastName.getOrElse("").trim + tag.firstName.getOrElse("").trim + tag.webTitle
tagPages.alphaIndexKey(indexString)
})

blocking {
saveToS3("contributors", tagPages.toPages(contributorsByNameOrder)(alphaTitle, tagPages.nameOrder))
Expand Down

0 comments on commit a7309bb

Please sign in to comment.