Skip to content

Commit

Permalink
update region targeting model
Browse files Browse the repository at this point in the history
  • Loading branch information
tomrf1 committed Feb 14, 2025
1 parent 9d6f287 commit 130da60
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
10 changes: 9 additions & 1 deletion support-frontend/app/admin/settings/LandingPageTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ object Status {
implicit val statusDecoder = deriveEnumerationDecoder[Status]
}

case class RegionTargeting(
targetedCountryGroups: List[String] = Nil,
)

object RegionTargeting {
implicit val codec: Codec[RegionTargeting] = deriveCodec
}

case class LandingPageTestTargeting(
countryGroups: List[String],
regionTargeting: RegionTargeting,
)

object LandingPageTestTargeting {
Expand Down
4 changes: 2 additions & 2 deletions support-frontend/assets/helpers/abTests/landingPageAbTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function getLandingPageParticipations(
const test = tests
.filter((test) => test.status == 'Live')
.find((test) => {
const { countryGroups } = test.targeting;
return countryGroups.includes(countryGroupId);
const { targetedCountryGroups } = test.targeting.regionTargeting;
return targetedCountryGroups.includes(countryGroupId);
});

if (test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export interface LandingPageVariant {
copy: LandingPageCopy;
}

interface RegionTargeting {
targetedCountryGroups: CountryGroupId[];
}

interface LandingPageTestTargeting {
regionTargeting: RegionTargeting;
}

interface LandingPageTestTargeting {
countryGroups: CountryGroupId[];
}
Expand Down
26 changes: 21 additions & 5 deletions support-frontend/test/services/LandingPageTestServiceSpec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package services

import admin.settings.{LandingPageCopy, LandingPageTest, LandingPageTestTargeting, LandingPageVariant, Status}
import admin.settings.{
LandingPageCopy,
LandingPageTest,
LandingPageTestTargeting,
LandingPageVariant,
RegionTargeting,
Status,
}
import org.scalatest.flatspec.AsyncFlatSpec
import org.scalatest.matchers.should.Matchers
import software.amazon.awssdk.services.dynamodb.model.AttributeValue
Expand All @@ -18,10 +25,17 @@ class LandingPageTestServiceSpec extends AsyncFlatSpec with Matchers {
.builder()
.m(
Map(
"countryGroups" -> AttributeValue
"regionTargeting" -> AttributeValue
.builder()
.l(
AttributeValue.builder().s("GBPCountries").build(),
.m(
Map(
"targetedCountryGroups" -> AttributeValue
.builder()
.l(
AttributeValue.builder().s("GBPCountries").build(),
)
.build(),
).asJava,
)
.build(),
).asJava,
Expand Down Expand Up @@ -58,7 +72,9 @@ class LandingPageTestServiceSpec extends AsyncFlatSpec with Matchers {
priority = 3,
status = Status.Live,
targeting = LandingPageTestTargeting(
countryGroups = List("GBPCountries"),
regionTargeting = RegionTargeting(
targetedCountryGroups = List("GBPCountries"),
),
),
variants = List(
LandingPageVariant(
Expand Down

0 comments on commit 130da60

Please sign in to comment.