Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions applications/app/services/NewspaperQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class NewspaperQuery(contentApiClient: ContentApiClient) extends Dates with GuLo
kicker = None,
brandingByEdition = Map.empty,
mediaAtom = None,
tests = None,
)
LinkSnap.make(fapiSnap)
}
Expand Down
3 changes: 3 additions & 0 deletions common/app/model/PressedProperties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package model.pressed

import com.gu.facia.api.utils.FaciaContentUtils
import com.gu.facia.api.{models => fapi, utils => fapiutils}
import com.gu.facia.client.models.Test
import common.Edition
import common.commercial.EditionBranding
import services.NewsletterData
Expand Down Expand Up @@ -34,6 +35,7 @@ final case class PressedProperties(
editionBrandings: Option[Seq[EditionBranding]],
atomId: Option[String],
newsletterData: Option[NewsletterData] = None,
tests: Option[List[Test]] = None,
) {
lazy val isPaidFor: Boolean = editionBrandings.exists(
_.exists(branding => branding.branding.exists(_.isPaid) && branding.edition == Edition.defaultEdition),
Expand Down Expand Up @@ -74,6 +76,7 @@ object PressedProperties {
Edition.byId(editionId) map (EditionBranding(_, branding))
}.toSeq),
atomId = FaciaContentUtils.atomId(content),
tests = content.tests,
)
}

Expand Down
1 change: 1 addition & 0 deletions common/app/services/FaciaContentConvert.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object FaciaContentConvert {
.toMap,
atomId = None,
mediaAtom = None,
tests = None,
)

PressedContent.make(curated, false)
Expand Down
1 change: 1 addition & 0 deletions common/test/layout/FrontTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class FrontTest extends AnyFlatSpec with Matchers with GuiceOneAppPerSuite {
brandingByEdition = Map.empty,
atomId = None,
mediaAtom = None,
tests = None,
)

LatestSnap.make(fapiLatestSnap)
Expand Down
31 changes: 31 additions & 0 deletions facia/app/controllers/front/FapiFrontJsonMinimal.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package controllers.front

import com.gu.facia.client.models.{Test, VariantMeta}
import model.PressedPage
import model.facia.PressedCollection
import model.pressed._
Expand Down Expand Up @@ -44,12 +45,42 @@ trait FapiFrontJsonMinimal {
"group" -> faciaContent.card.group,
"frontPublicationDate" -> faciaContent.properties.maybeFrontPublicationDate,
"supporting" -> getSupporting(faciaContent),
"tests" -> getMinimalTests(faciaContent.properties.tests),
)
.fields
.filterNot { case (_, v) => v == JsNull },
)
}

private case class MinimalTest(
testUuid: String,
variantMeta: List[VariantMeta],
startDate: Option[Long],
expiryDate: Option[Long],
hasManuallyEndedOnThisTrail: Boolean,
)

implicit private val minimalTestWrites: Writes[MinimalTest] = Json.writes[MinimalTest]

private def getMinimalTests(tests: Option[List[Test]]): JsValue =
tests.filter(_.nonEmpty) match {
case Some(tests) =>
JsArray(
tests.map(test =>
Json.toJson(
MinimalTest(
testUuid = test.testUuid,
variantMeta = test.variantMeta,
startDate = test.startDate,
expiryDate = test.expiryDate,
hasManuallyEndedOnThisTrail = test.hasManuallyEndedOnThisTrail,
),
),
),
)
case None => JsNull
}

private def getSupporting(faciaContent: PressedContent): JsValue =
faciaContent match {
case curatedContent: CuratedContent if curatedContent.supportingContent.nonEmpty =>
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Dependencies {
val identityLibVersion = "4.31"
val awsVersion = "2.46.18"
val capiVersion = "47.0.0"
val faciaVersion = "34.0.0"
val faciaVersion = "37.0.0"
val dispatchVersion = "0.13.1"
val romeVersion = "1.0"
val jerseyVersion = "1.19.4"
Expand Down
Loading