From eea3de6b167c7c274c23680ac3981dbeb177131e Mon Sep 17 00:00:00 2001 From: Max Duval Date: Thu, 13 Jun 2024 15:04:54 +0100 Subject: [PATCH] feat: add Euro 2024 header on overview --- .../controllers/WallchartController.scala | 40 ++++++++++++++----- .../football/views/wallchart/embed.scala.html | 2 +- .../football/views/wallchart/page.scala.html | 5 ++- .../views/wallchart/wallchart.scala.html | 12 ++++-- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/sport/app/football/controllers/WallchartController.scala b/sport/app/football/controllers/WallchartController.scala index 964187c1013..187f8344234 100644 --- a/sport/app/football/controllers/WallchartController.scala +++ b/sport/app/football/controllers/WallchartController.scala @@ -9,10 +9,16 @@ import football.model.{CompetitionStage, Groups, KnockoutSpider} import pa.{FootballMatch} import java.time.ZonedDateTime +import scala.concurrent.Future +import contentapi.ContentApiClient +import conf.switches.Switches +import common.Edition +import model.content.InteractiveAtom class WallchartController( competitionsService: CompetitionsService, val controllerComponents: ControllerComponents, + val contentApiClient: ContentApiClient, )(implicit context: ApplicationContext) extends BaseController with GuLogging @@ -28,7 +34,7 @@ class WallchartController( def renderWallchartEmbed(competitionTag: String): Action[AnyContent] = renderWallchart(competitionTag, true) def renderWallchart(competitionTag: String, embed: Boolean = false): Action[AnyContent] = - Action { implicit request => + Action.async { implicit request => competitionsService .competitionsWithTag(competitionTag) .map { competition => @@ -40,18 +46,30 @@ class WallchartController( val competitionStages = new CompetitionStage(competitionsService.competitions) .stagesFromCompetition(competition, KnockoutSpider.orderings) val nextMatch = WallchartController.nextMatch(competition.matches, ZonedDateTime.now()) - Cached(60) { - if (embed) - RevalidatableResult.Ok( - football.views.html.wallchart.embed(page, competition, competitionStages, nextMatch), - ) - else - RevalidatableResult.Ok( - football.views.html.wallchart.page(page, competition, competitionStages, nextMatch), - ) + val futureAtom = if (Switches.Euro2024Header.isSwitchedOn && competitionTag == "euro-2024") { + val id = "/atom/interactive/interactives/2023/01/euros-2024/tables-euros-2024-header" + val edition = Edition(request) + contentApiClient + .getResponse(contentApiClient.item(id, edition)) + .map(_.interactive.map(InteractiveAtom.make(_))) + .recover { case _ => None } + } else Future.successful(None) + + futureAtom.map { maybeAtom => + Cached(60) { + if (embed) + RevalidatableResult.Ok( + football.views.html.wallchart.embed(page, competition, competitionStages, nextMatch), + ) + else + RevalidatableResult.Ok( + football.views.html.wallchart.page(page, competition, competitionStages, nextMatch, maybeAtom), + ) + } } + } - .getOrElse(NotFound) + .getOrElse(Future.successful(NotFound)) } def renderGroupTablesEmbed(competitionTag: String): Action[AnyContent] = diff --git a/sport/app/football/views/wallchart/embed.scala.html b/sport/app/football/views/wallchart/embed.scala.html index d673a627db4..2e098f49539 100644 --- a/sport/app/football/views/wallchart/embed.scala.html +++ b/sport/app/football/views/wallchart/embed.scala.html @@ -8,7 +8,7 @@
- @wallchart(competition, competitionStages, next) + @wallchart(competition, competitionStages, next, None) @fragments.analytics.base()(page, request, context)
diff --git a/sport/app/football/views/wallchart/page.scala.html b/sport/app/football/views/wallchart/page.scala.html index 7f495b6ac94..9ab5816ef5b 100644 --- a/sport/app/football/views/wallchart/page.scala.html +++ b/sport/app/football/views/wallchart/page.scala.html @@ -1,9 +1,10 @@ @import _root_.football.model.CompetitionStageLike @import model.{Competition, Page} +@import model.content.InteractiveAtom -@(page: Page, competition: Competition, competitionStages: List[CompetitionStageLike], next: Option[pa.FootballMatch])(implicit request: RequestHeader, context: model.ApplicationContext) +@(page: Page, competition: Competition, competitionStages: List[CompetitionStageLike], next: Option[pa.FootballMatch], maybeAtom: Option[InteractiveAtom])(implicit request: RequestHeader, context: model.ApplicationContext) @mainLegacy(page, Some("football")){ }{ - @wallchart(competition, competitionStages, next) + @wallchart(competition, competitionStages, next, maybeAtom) } diff --git a/sport/app/football/views/wallchart/wallchart.scala.html b/sport/app/football/views/wallchart/wallchart.scala.html index f942dd3bc23..2331287959a 100644 --- a/sport/app/football/views/wallchart/wallchart.scala.html +++ b/sport/app/football/views/wallchart/wallchart.scala.html @@ -2,10 +2,16 @@ @import model.Competition @import conf.switches.Switches @import conf.Configuration +@import model.ApplicationContext +@import model.content.InteractiveAtom -@(competition: Competition, competitionStages: List[CompetitionStageLike], next: Option[pa.FootballMatch])(implicit request: RequestHeader) -
- +@(competition: Competition, competitionStages: List[CompetitionStageLike], next: Option[pa.FootballMatch], maybeAtom: Option[InteractiveAtom])(implicit request: RequestHeader, context: ApplicationContext) +
+ @maybeAtom.map{ atom => +
+ @views.html.fragments.atoms.interactive(atom, shouldFence = false) +
+ } @competitionStages.map { case knockoutStage: _root_.football.model.KnockoutSpider => {