in app/logic/CapiPrefiller.scala [94:129]
private[logic] def pickKicker(content: Content): Option[String] =
content.tags.find(tag => tag.`type` == TagType.Series) match {
// If we have a series tag, use the web title for the series tag
case Some(tag) => Some(tag.webTitle)
// Otherwise...
case _ =>
content.tags.find(tag => tag.`type` == TagType.Tone) match {
// If we have a tone tag that we know how to use, use that...
case Some(tag) if pluralKickers.contains(tag.id) => Some(tag.webTitle)
case Some(tag) if singularKickers.contains(tag.id) =>
Some(tag.webTitle.dropRight(1))
case Some(tag) if bylineKickers.contains(tag.id) =>
content.fields.flatMap(f => f.byline)
// Otherwise...
case _ =>
content.tags.headOption match {
// If there are no tags at all, there's not going to be a kicker!
case None => None
// If there IS a tag and it hasn't been used in the content title, use that...
case Some(firstTag)
if !content.webTitle.contains(firstTag.webTitle) =>
Some(firstTag.webTitle)
// Otherwise...
case Some(firstTag) =>
content.tags.tail.headOption match {
// If there is a second tag, and it's not in the title, use that.
case Some(secondTag)
if !content.webTitle.contains(secondTag.webTitle) =>
Some(secondTag.webTitle)
// Otherwise...
// Use the first tag after all!
case _ => Some(firstTag.webTitle)
}
}
}
}