Skip to content

Commit

Permalink
Merge pull request #25834 from guardian/pf/refactor-contributor-index
Browse files Browse the repository at this point in the history
  • Loading branch information
bryophyta authored Jan 18, 2023
2 parents 60b9e42 + 993fbd0 commit 3768ce5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion admin/app/jobs/RebuildIndexJob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@ 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.concat(tag.firstName.getOrElse("").trim).concat(tag.webTitle)
tagPages.alphaIndexKey(indexString)
})

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

0 comments on commit 3768ce5

Please sign in to comment.