From 0191a35f93c72c366a3d296cd5639da5d64033d2 Mon Sep 17 00:00:00 2001 From: Dominik Lander Date: Wed, 7 Aug 2024 10:17:14 +0100 Subject: [PATCH] Test using non-lite versions of fronts --- common/app/experiments/Experiments.scala | 12 +++++++++++- facia/app/controllers/FaciaController.scala | 18 +++++++++++++----- .../services/dotcomrendering/FaciaPicker.scala | 6 +++++- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/common/app/experiments/Experiments.scala b/common/app/experiments/Experiments.scala index c1f7734615c0..0059d31e86e1 100644 --- a/common/app/experiments/Experiments.scala +++ b/common/app/experiments/Experiments.scala @@ -11,9 +11,10 @@ import java.time.LocalDate object ActiveExperiments extends ExperimentsDefinition { override val allExperiments: Set[Experiment] = Set( - DarkModeWeb, UpdatedHeaderDesign, MastheadWithHighlights, + DarkModeWeb, + RemoveLiteFronts, TagLinkDesign, ) implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this) @@ -47,6 +48,15 @@ object DarkModeWeb participationGroup = Perc0D, ) +object RemoveLiteFronts + extends Experiment( + name = "remove-lite-fronts", + description = "Get the full pressed page of a front instead of the lite version", + owners = Seq(Owner.withEmail("dotcom.platform@theguardian.com")), + sellByDate = LocalDate.of(2024, 10, 30), + participationGroup = Perc0E, + ) + object TagLinkDesign extends Experiment( name = "tag-link-design", diff --git a/facia/app/controllers/FaciaController.scala b/facia/app/controllers/FaciaController.scala index cf6fabb2db0d..0a4e4956d30d 100644 --- a/facia/app/controllers/FaciaController.scala +++ b/facia/app/controllers/FaciaController.scala @@ -6,6 +6,7 @@ import common._ import conf.Configuration import conf.switches.Switches.InlineEmailStyles import controllers.front._ +import experiments.{ActiveExperiments, RemoveLiteFronts} import http.HttpPreconnections import implicits.GUHeaders import layout.slices._ @@ -135,11 +136,13 @@ trait FaciaController FrontHeadline.headlineNotFound } + val requestType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) liteRequestType else fullRequestType + if (!ConfigAgent.frontExistsInConfig(path)) { successful(Cached(CacheTime.Facia)(notFound())) } else { frontJsonFapi - .get(path, liteRequestType) + .get(path, requestType) .map(_.fold[CacheableResult](notFound())(FrontHeadline.renderEmailHeadline)) .map(Cached(CacheTime.Facia)) } @@ -180,7 +183,9 @@ trait FaciaController Cached(CacheTime.Facia)(JsonComponent.fromWritable(JsObject(Nil))), ) } else { - frontJsonFapi.get(path, liteRequestType).map { resp => + val requestType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) liteRequestType else fullRequestType + + frontJsonFapi.get(path, requestType).map { resp => Cached(CacheTime.Facia)(JsonComponent.fromWritable(resp match { case Some(pressedPage) => FapiFrontJsonMinimal.get(pressedPage) case None => JsObject(Nil) @@ -220,7 +225,10 @@ trait FaciaController import PressedPage.pressedPageFormat private[controllers] def renderFrontPressResult(path: String)(implicit request: RequestHeader): Future[Result] = { - val futureFaciaPage: Future[Option[(PressedPage, Boolean)]] = frontJsonFapi.get(path, liteRequestType).flatMap { + val requestType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) liteRequestType else fullRequestType + val NonAdFreeType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) LiteType else FullType + + val futureFaciaPage: Future[Option[(PressedPage, Boolean)]] = frontJsonFapi.get(path, requestType).flatMap { case Some(faciaPage: PressedPage) => val pageContainsTargetedCollections = TargetedCollections.pageContainsTargetedCollections(faciaPage) val regionalFaciaPage = TargetedCollections.processTargetedCollections( @@ -235,8 +243,8 @@ trait FaciaController List(), ) } - if (faciaPage.collections.isEmpty && liteRequestType == LiteAdFreeType) { - frontJsonFapi.get(path, LiteType).map(_.map(f => (f, false))) + if (faciaPage.collections.isEmpty && (requestType == FullAdFreeType || requestType == LiteAdFreeType)) { + frontJsonFapi.get(path, NonAdFreeType).map(_.map(f => (f, false))) } else Future.successful(Some(regionalFaciaPage, pageContainsTargetedCollections)) case None => Future.successful(None) } diff --git a/facia/app/services/dotcomrendering/FaciaPicker.scala b/facia/app/services/dotcomrendering/FaciaPicker.scala index 165676e1bb87..3b49d2ae81bc 100644 --- a/facia/app/services/dotcomrendering/FaciaPicker.scala +++ b/facia/app/services/dotcomrendering/FaciaPicker.scala @@ -2,6 +2,7 @@ package services.dotcomrendering import common.{Edition, GuLogging} import conf.switches.Switches.{DCRFronts, DCRNetworkFronts} +import experiments.{ActiveExperiments, RemoveLiteFronts} import implicits.Requests._ import model.PressedPage import model.facia.PressedCollection @@ -105,6 +106,7 @@ object FaciaPicker extends GuLogging { lazy val dcrCouldRender = checks.values.forall(checkValue => checkValue) lazy val isNetworkFront = faciaPage.isNetworkFront lazy val dcrNetworkFrontsSwitchEnabled = DCRNetworkFronts.isSwitchedOn + lazy val isFullFrontRequest = ActiveExperiments.isParticipating(RemoveLiteFronts) val tier = decideTier( @@ -117,7 +119,7 @@ object FaciaPicker extends GuLogging { dcrNetworkFrontsSwitchEnabled, ) - logTier(faciaPage, dcrCouldRender, checks, tier) + logTier(faciaPage, dcrCouldRender, checks, tier, isFullFrontRequest) tier } @@ -148,6 +150,7 @@ object FaciaPicker extends GuLogging { dcrCouldRender: Boolean, checks: Map[String, Boolean], tier: RenderType, + isFullFrontRequest: Boolean, )(implicit request: RequestHeader): Unit = { val tierReadable = if (tier == RemoteRender) "dotcomcomponents" else "web" val checksToString = checks.map { case (key, value) => @@ -160,6 +163,7 @@ object FaciaPicker extends GuLogging { "dcrCouldRender" -> dcrCouldRender.toString, "isFront" -> "true", "tier" -> tierReadable, + "isFullFrontRequest" -> isFullFrontRequest.toString, ) ++ checksToString DotcomFrontsLogger.logger.logRequest(s"front executing in $tierReadable", properties, faciaPage)