in football/src/main/scala/com/gu/mobile/notifications/football/notificationbuilders/MatchStatusNotificationBuilder.scala [15:57]
def build(
triggeringEvent: FootballMatchEvent,
matchInfo: MatchDay,
previousEvents: List[FootballMatchEvent],
articleId: Option[String]
): FootballMatchStatusPayload = {
val topics = List(
Topic(TopicTypes.FootballTeam, matchInfo.homeTeam.id),
Topic(TopicTypes.FootballTeam, matchInfo.awayTeam.id),
Topic(TopicTypes.FootballMatch, matchInfo.id)
)
val allEvents = triggeringEvent :: previousEvents
val goals = allEvents.collect { case g: Goal => g }
val score = Score.fromGoals(matchInfo.homeTeam, matchInfo.awayTeam, goals)
val status = statuses.getOrElse(matchInfo.matchStatus, matchInfo.matchStatus)
FootballMatchStatusPayload(
title = Some(eventTitle(triggeringEvent)),
message = Some(mainMessage(triggeringEvent, transformTeamName(matchInfo.homeTeam.name), transformTeamName(matchInfo.awayTeam.name), score, status)),
sender = "mobile-notifications-football-lambda",
awayTeamName = transformTeamName(matchInfo.awayTeam.name),
awayTeamScore = score.away,
awayTeamMessage = teamMessage(matchInfo.awayTeam, allEvents),
awayTeamId = matchInfo.awayTeam.id,
homeTeamName = transformTeamName(matchInfo.homeTeam.name),
homeTeamScore = score.home,
homeTeamMessage = teamMessage(matchInfo.homeTeam, allEvents),
homeTeamId = matchInfo.homeTeam.id,
matchId = matchInfo.id,
competitionName = matchInfo.competition.map(_.name),
venue = matchInfo.venue.map(_.name).filter(_.nonEmpty),
matchInfoUri = new URI(s"$mapiHost/sport/football/matches/${matchInfo.id}"),
articleUri = articleId.map(id => new URI(s"$mapiHost/items/$id")),
importance = importance(triggeringEvent),
topic = topics,
matchStatus = status,
eventId = UUID.nameUUIDFromBytes(triggeringEvent.eventId.getBytes).toString,
debug = false,
dryRun = None
)
}