Skip to content

Commit

Permalink
Test using non-lite versions of fronts
Browse files Browse the repository at this point in the history
  • Loading branch information
domlander committed Aug 7, 2024
1 parent 12ce055 commit 0191a35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 11 additions & 1 deletion common/app/experiments/Experiments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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("[email protected]")),
sellByDate = LocalDate.of(2024, 10, 30),
participationGroup = Perc0E,
)

object TagLinkDesign
extends Experiment(
name = "tag-link-design",
Expand Down
18 changes: 13 additions & 5 deletions facia/app/controllers/FaciaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand All @@ -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)
}
Expand Down
6 changes: 5 additions & 1 deletion facia/app/services/dotcomrendering/FaciaPicker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -117,7 +119,7 @@ object FaciaPicker extends GuLogging {
dcrNetworkFrontsSwitchEnabled,
)

logTier(faciaPage, dcrCouldRender, checks, tier)
logTier(faciaPage, dcrCouldRender, checks, tier, isFullFrontRequest)

tier
}
Expand Down Expand Up @@ -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) =>
Expand All @@ -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)
Expand Down

0 comments on commit 0191a35

Please sign in to comment.