def matchSummaryMf2()

in sport/app/football/controllers/MoreOnMatchController.scala [378:440]


  def matchSummaryMf2(year: String, month: String, day: String, team1: String, team2: String): Action[AnyContent] =
    Action.async { implicit request =>
      val contentDate = DateHelpers.parseLocalDate(year, month, day)

      val maybeResponse: Option[Future[Result]] =
        competitionsService.matchFor(interval(contentDate), team1, team2) map { theMatch =>
          val related: Future[Seq[ContentType]] = loadMoreOn(request, theMatch)
          // We are only interested in content with exactly 2 team tags
          related map { _ filter hasExactlyTwoTeams } map { filtered =>
            Cached(if (theMatch.isLive) 10 else 300) {
              lazy val competition = competitionsService.competitionForMatch(theMatch.id)
              lazy val homeTeamResults = competition.map(_.teamResults(theMatch.homeTeam.id).take(5))

              implicit val dateToTimestampWrites = play.api.libs.json.JodaWrites.JodaDateTimeNumberWrites
              JsonComponent(
                "items" -> Json.arr(
                  Json.obj(
                    "id" -> theMatch.id,
                    "date" -> theMatch.date,
                    "venue" -> theMatch.venue.map(_.name),
                    "isLive" -> theMatch.isLive,
                    "isResult" -> theMatch.isResult,
                    "isLiveOrIsResult" -> (theMatch.isResult || theMatch.isLive),
                    "homeTeam" -> Json.obj(
                      "name" -> theMatch.homeTeam.name,
                      "id" -> theMatch.homeTeam.id,
                      "score" -> theMatch.homeTeam.score,
                      "crest" -> s"${Configuration.staticSport.path}/football/crests/120/${theMatch.homeTeam.id}.png",
                      "scorers" -> theMatch.homeTeam.scorers
                        .getOrElse("")
                        .split(",")
                        .map(scorer => {
                          Json.obj(
                            "scorer" -> scorer.replace("(", "").replace(")", ""),
                          )
                        }),
                    ),
                    "awayTeam" -> Json.obj(
                      "name" -> theMatch.awayTeam.name,
                      "id" -> theMatch.awayTeam.id,
                      "score" -> theMatch.awayTeam.score,
                      "crest" -> s"${Configuration.staticSport.path}/football/crests/120/${theMatch.awayTeam.id}.png",
                      "scorers" -> theMatch.awayTeam.scorers
                        .getOrElse("")
                        .split(",")
                        .map(scorer => {
                          Json.obj(
                            "scorer" -> scorer.replace("(", "").replace(")", ""),
                          )
                        }),
                    ),
                    "competition" -> Json.obj(
                      "fullName" -> competition.map(_.fullName),
                    ),
                  ),
                ),
              )
            }
          }
        }

      maybeResponse.getOrElse(Future.successful(Cached(30) { JsonNotFound() }))
    }