Skip to content

Commit

Permalink
feat: add Euro 2024 header on overview
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Jun 13, 2024
1 parent 86c3784 commit eea3de6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
40 changes: 29 additions & 11 deletions sport/app/football/controllers/WallchartController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =>
Expand All @@ -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] =
Expand Down
2 changes: 1 addition & 1 deletion sport/app/football/views/wallchart/embed.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</head>
<body id="top" itemscope itemtype="http://schema.org/WebPage">
<div id="js-context" class="football-wallchart-embed">
@wallchart(competition, competitionStages, next)
@wallchart(competition, competitionStages, next, None)
@fragments.analytics.base()(page, request, context)
</div>
</body>
Expand Down
5 changes: 3 additions & 2 deletions sport/app/football/views/wallchart/page.scala.html
Original file line number Diff line number Diff line change
@@ -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)
}
12 changes: 9 additions & 3 deletions sport/app/football/views/wallchart/wallchart.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<div class="l-side-margins wc-overview">

@(competition: Competition, competitionStages: List[CompetitionStageLike], next: Option[pa.FootballMatch], maybeAtom: Option[InteractiveAtom])(implicit request: RequestHeader, context: ApplicationContext)
<div class="l-side-margins wc-overview content">
@maybeAtom.map{ atom =>
<div class="gs-container">
@views.html.fragments.atoms.interactive(atom, shouldFence = false)
</div>
}
@competitionStages.map {
case knockoutStage: _root_.football.model.KnockoutSpider => {
<div class="facia-container facia-container--layout-content">
Expand Down

0 comments on commit eea3de6

Please sign in to comment.