FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PageSkin line items now get JSONified and admin display with their se… · devhttps/frontend@45ce4e2 · GitHub

Commit 45ce4e2

Browse files
Jerome Eteve
committed
PageSkin line items now get JSONified and admin display with their serie(s)
1 parent f0e7221 commit 45ce4e2

5 files changed

Lines changed: 46 additions & 19 deletions

File tree

‎admin/app/dfp/DfpDataExtractor.scala‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ case class DfpDataExtractor(
4747
isR2Only = lineItem.targeting.targetsR2Only,
4848
targetsAdTest = lineItem.targeting.hasAdTestTargetting,
4949
adTestValue = lineItem.targeting.adTestValue,
50-
keywords = lineItem.targeting.keyValues
50+
keywords = lineItem.targeting.keywordValues,
51+
series = lineItem.targeting.serieValues
5152
)
5253
}
5354
}

‎admin/app/views/commercial/pageskins.scala.html‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
}
3636
</ul>
3737
}
38+
@if(sponsorship.series.nonEmpty) {
39+
<small>Series:</small>
40+
<ul>
41+
@for(serie <- sponsorship.series) {
42+
<li>@serie</li>
43+
}
44+
</ul>
45+
}
3846
</li>
3947
}
4048

‎common/app/common/dfp/DfpData.scala‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ object CustomTargetSet {
8585

8686
implicit val customTargetSetFormats: Format[CustomTargetSet] = Json.format[CustomTargetSet]
8787

88+
8889
}
8990

9091

@@ -148,13 +149,13 @@ case class GuTargeting(adUnitsIncluded: Seq[GuAdUnit],
148149
geoTargetsExcluded: Seq[GeoTarget],
149150
customTargetSets: Seq[CustomTargetSet]) {
150151

151-
val keyValues: Seq[String] = {
152-
for {
153-
targetSet <- customTargetSets
154-
target <- targetSet.targets if target.isKeywordTag
155-
targetValue <- target.values
156-
} yield targetValue
157-
}
152+
// This is local pure helper function:
153+
private val tagValues = ( ( customTargetSets: Seq[CustomTargetSet],
154+
isGoodTag: CustomTarget => Boolean )
155+
=> customTargetSets.flatMap( _.targets ).filter( isGoodTag ).flatMap( _.values ) )
156+
157+
val serieValues: Seq[String] = tagValues( customTargetSets, _.isSeriesTag )
158+
val keywordValues: Seq[String] = tagValues( customTargetSets, _.isKeywordTag )
158159

159160
val adTestValue: Option[String] = {
160161
val testValues = for {

‎common/app/common/dfp/PageSkinSponsorship.scala‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ case class PageSkinSponsorship(lineItemName: String,
1616
isR2Only: Boolean, // Legacy platform.
1717
targetsAdTest: Boolean,
1818
adTestValue: Option[String],
19-
keywords: Seq[String])
19+
keywords: Seq[String],
20+
series: Seq[String]
21+
)
2022

2123
object PageSkinSponsorship {
2224
implicit val pageskinSponsorShipFormat: Format[PageSkinSponsorship] = Json.format[PageSkinSponsorship]

‎common/test/common/dfp/PageskinAdAgentTest.scala‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,66 @@ class PageskinAdAgentTest extends FlatSpec with Matchers {
2020
val articleMeta = MetaData.make("", None, "The title", None)
2121

2222
val examplePageSponsorships = Seq(
23-
PageSkinSponsorship("lineItemName",
23+
PageSkinSponsorship(
24+
"lineItemName",
2425
1234L,
2526
Seq("business/front"),
2627
Seq(Uk),
2728
Seq("United Kingdom"),
2829
isR2Only = false,
2930
targetsAdTest = false,
3031
adTestValue = None,
31-
keywords = Seq.empty),
32-
PageSkinSponsorship("lineItemName2",
32+
keywords = Seq.empty,
33+
series = Seq.empty
34+
),
35+
PageSkinSponsorship(
36+
"lineItemName2",
3337
12345L,
3438
Seq("music/front"),
3539
Nil,
3640
Nil,
3741
isR2Only = false,
3842
targetsAdTest = false,
3943
adTestValue = None,
40-
keywords = Seq.empty),
41-
PageSkinSponsorship("lineItemName3",
44+
keywords = Seq.empty,
45+
series = Seq.empty
46+
),
47+
PageSkinSponsorship(
48+
"lineItemName3",
4249
123456L,
4350
Seq("sport"),
4451
Nil,
4552
Nil,
4653
isR2Only = false,
4754
targetsAdTest = false,
4855
adTestValue = None,
49-
keywords = Seq.empty),
50-
PageSkinSponsorship("lineItemName4",
56+
keywords = Seq.empty,
57+
series = Seq.empty
58+
),
59+
PageSkinSponsorship(
60+
"lineItemName4",
5161
1234567L,
5262
Seq("testSport/front"),
5363
Seq(Uk),
5464
Seq("United Kingdom"),
5565
isR2Only = false,
5666
targetsAdTest = true,
5767
adTestValue = Some("6"),
58-
keywords = Seq.empty),
59-
PageSkinSponsorship("lineItemName5",
68+
keywords = Seq.empty,
69+
series = Seq.empty
70+
),
71+
PageSkinSponsorship(
72+
"lineItemName5",
6073
123458L,
6174
Seq("sport-index"),
6275
Seq(Uk),
6376
Nil,
6477
isR2Only = false,
6578
targetsAdTest = false,
6679
adTestValue = None,
67-
keywords = Seq("sport-keyword"))
80+
keywords = Seq("sport-keyword"),
81+
series = Seq.empty
82+
)
6883
)
6984

7085
private object TestPageskinAdAgent extends PageskinAdAgent {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL