Skip to content

Commit

Permalink
Remove Euro2024Header feature switch
Browse files Browse the repository at this point in the history
  • Loading branch information
domlander committed Jul 31, 2024
1 parent 8274f45 commit 42ef50d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 62 deletions.
10 changes: 0 additions & 10 deletions common/app/conf/switches/JournalismSwitches.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,4 @@ trait JournalismSwitches {
sellByDate = never,
exposeClientSide = true,
)

val Euro2024Header = Switch(
SwitchGroup.Journalism,
name = "euro-2024-header",
description = "Show the Euro 2024 interactive atom header on football pages",
owners = Seq(Owner.withEmail("[email protected]")),
safeState = Off,
sellByDate = LocalDate.of(2024, 7, 31),
exposeClientSide = true,
)
}
34 changes: 10 additions & 24 deletions sport/app/football/controllers/FixturesController.scala
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
package football.controllers

import common.Edition
import common.ImplicitControllerExecutionContext
import feed.CompetitionsService
import football.model._
import model._
import model.content.InteractiveAtom
import contentapi.ContentApiClient
import java.time.LocalDate
import pa.FootballTeam
import play.api.mvc.{Action, AnyContent, ControllerComponents}
import scala.concurrent.Future
import conf.switches.Switches

class FixturesController(
val competitionsService: CompetitionsService,
val controllerComponents: ControllerComponents,
val contentApiClient: ContentApiClient,
)(implicit context: ApplicationContext)
extends MatchListController
with CompetitionFixtureFilters
with ImplicitControllerExecutionContext {
with CompetitionFixtureFilters {

private def fixtures(date: LocalDate): FixturesList = FixturesList(date, competitionsService.competitions)
private val page = new FootballPage("football/fixtures", "football", "All fixtures")
Expand Down Expand Up @@ -87,21 +80,14 @@ class FixturesController(

private def renderTagFixtures(date: LocalDate, tag: String): Action[AnyContent] =
getTagFixtures(date, tag)
.map { case (page, fixtures) =>
Action.async { implicit request =>
tag match {
case "euro-2024" if Switches.Euro2024Header.isSwitchedOn =>
val id = "/atom/interactive/interactives/2023/01/euros-2024/match-centre-euros-2024-header"
val edition = Edition(request)
contentApiClient
.getResponse(contentApiClient.item(id, edition))
.map(_.interactive.map(InteractiveAtom.make(_)))
.recover { case _ => None }
.map(renderMatchList(page, fixtures, filters, _))
case _ =>
Future.successful(renderMatchList(page, fixtures, filters, None))
}
}
}
.map(result =>
Action { implicit request =>
renderMatchList(
result._1,
result._2,
filters,
)
},
)
.getOrElse(Action(NotFound))
}
2 changes: 1 addition & 1 deletion sport/app/football/controllers/LeagueTableController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class LeagueTableController(
s"${table.competition.fullName} table",
)

val futureAtom = if (Switches.Euro2024Header.isSwitchedOn && competition == "euro-2024") {
val futureAtom = if (competition == "euro-2024") {
val id = "/atom/interactive/interactives/2023/01/euros-2024/tables-euros-2024-header"
val edition = Edition(request)
contentApiClient
Expand Down
23 changes: 4 additions & 19 deletions sport/app/football/controllers/MatchDayController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ import java.time.LocalDate
import model._
import football.model._
import common.{Edition, JsonComponent}
import contentapi.ContentApiClient
import model.content.InteractiveAtom
import common.ImplicitControllerExecutionContext
import scala.concurrent.Future
import conf.switches.Switches

class MatchDayController(
val competitionsService: CompetitionsService,
val controllerComponents: ControllerComponents,
val contentApiClient: ContentApiClient,
)(implicit context: ApplicationContext)
extends MatchListController
with CompetitionLiveFilters
with ImplicitControllerExecutionContext {
with CompetitionLiveFilters {

def liveMatchesJson(): Action[AnyContent] = liveMatches()
def liveMatches(): Action[AnyContent] =
Expand Down Expand Up @@ -48,26 +41,18 @@ class MatchDayController(
competitionMatchesFor(competitionTag, year, month, day)

private def renderCompetitionMatches(competitionTag: String, date: LocalDate): Action[AnyContent] =
Action.async { implicit request =>
Action { implicit request =>
lookupCompetition(competitionTag)
.map { competition =>
val webTitle =
if (date == LocalDate.now(Edition.defaultEdition.timezoneId)) s"Today's ${competition.fullName} matches"
else s" ${competition.fullName} matches"
val page = new FootballPage(s"football/$competitionTag/live", "football", webTitle)
val matches = CompetitionMatchDayList(competitionsService.competitions, competition.id, date)
if (Switches.Euro2024Header.isSwitchedOn) {
val id = "/atom/interactive/interactives/2023/01/euros-2024/match-centre-euros-2024-header"
val edition = Edition(request)
contentApiClient
.getResponse(contentApiClient.item(id, edition))
.map(_.interactive.map(InteractiveAtom.make(_)))
.recover { case _ => None }
.map(renderMatchList(page, matches, filters, _))
} else Future.successful(renderMatchList(page, matches, filters))
renderMatchList(page, matches, filters)
}
.getOrElse {
Future.successful(NotFound)
NotFound
}
}

Expand Down
2 changes: 1 addition & 1 deletion sport/app/football/controllers/WallchartController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class WallchartController(
val competitionStages = new CompetitionStage(competitionsService.competitions)
.stagesFromCompetition(competition, KnockoutSpider.orderings)
val nextMatch = WallchartController.nextMatch(competition.matches, ZonedDateTime.now())
val futureAtom = if (Switches.Euro2024Header.isSwitchedOn && competitionTag == "euro-2024") {
val futureAtom = if (competitionTag == "euro-2024") {
val id = "/atom/interactive/interactives/2023/01/euros-2024/tables-euros-2024-header"
val edition = Edition(request)
contentApiClient
Expand Down
9 changes: 2 additions & 7 deletions sport/test/controllers/FixturesControllerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ import org.scalatest.matchers.should.Matchers
with WithMaterializer
with BeforeAndAfterAll
with WithTestApplicationContext
with WithTestWsClient
with WithTestContentApiClient {
with WithTestWsClient {

val fixturesUrl = "/football/fixtures"
val fixtureForUrl = "/football/fixtures/2012/oct/20"
val tag = "premierleague"

lazy val fixturesController =
new FixturesController(
testCompetitionsService,
play.api.test.Helpers.stubControllerComponents(),
testContentApiClient,
)
new FixturesController(testCompetitionsService, play.api.test.Helpers.stubControllerComponents())

"can load the all fixtures page" in {
val result = fixturesController.allFixtures()(TestRequest())
Expand Down

0 comments on commit 42ef50d

Please sign in to comment.