Skip to content

Commit

Permalink
Merge pull request #27389 from guardian/doml/lite
Browse files Browse the repository at this point in the history
Test using non-lite versions of fronts
  • Loading branch information
domlander authored Aug 23, 2024
2 parents 08f32f5 + 2d919e1 commit 1673651
Show file tree
Hide file tree
Showing 3 changed files with 26 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,13 +11,23 @@ import java.time.LocalDate
object ActiveExperiments extends ExperimentsDefinition {
override val allExperiments: Set[Experiment] =
Set(
DarkModeWeb,
RemoveLiteFronts,
UpdatedHeaderDesign,
MastheadWithHighlights,
DarkModeWeb,
)
implicit val canCheckExperiment: CanCheckExperiment = new CanCheckExperiment(this)
}

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 = Perc0A,
)

object UpdatedHeaderDesign
extends Experiment(
name = "updated-header-design",
Expand Down
15 changes: 10 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 @@ -139,7 +140,7 @@ trait FaciaController
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 +181,7 @@ trait FaciaController
Cached(CacheTime.Facia)(JsonComponent.fromWritable(JsObject(Nil))),
)
} else {
frontJsonFapi.get(path, liteRequestType).map { resp =>
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 +221,9 @@ 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 NonAdFreeType = if (ActiveExperiments.isParticipating(RemoveLiteFronts)) FullType else LiteType

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 +238,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 Expand Up @@ -527,6 +530,8 @@ trait FaciaController
if (request.isAdFree) FullAdFreeType else FullType
def liteRequestType(implicit request: RequestHeader): PressedPageType =
if (request.isAdFree) LiteAdFreeType else LiteType
def requestType(implicit request: RequestHeader): PressedPageType =
if (ActiveExperiments.isParticipating(RemoveLiteFronts)) fullRequestType else liteRequestType

def ampRsaPublicKey: Action[AnyContent] = {
Action {
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 @@ -106,6 +107,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 @@ -118,7 +120,7 @@ object FaciaPicker extends GuLogging {
dcrNetworkFrontsSwitchEnabled,
)

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

tier
}
Expand Down Expand Up @@ -149,6 +151,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 @@ -161,6 +164,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 1673651

Please sign in to comment.