Skip to content

Commit

Permalink
Add support for section (s) in im targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyford authored and domlander committed Mar 27, 2024
1 parent 8d765e0 commit b7a8bc5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions admin/app/dfp/DfpDataExtractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ case class DfpDataExtractor(lineItems: Seq[GuLineItem], invalidLineItems: Seq[Gu
keywords = soFar.keywords ++ lineItem.inlineMerchandisingTargetedKeywords,
series = soFar.series ++ lineItem.inlineMerchandisingTargetedSeries,
contributors = soFar.contributors ++ lineItem.inlineMerchandisingTargetedContributors,
sections = soFar.sections ++ lineItem.inlineMerchandisingTargetedSections,
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions admin/app/tools/DfpLink.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ object CapiLink {
def keywordPage(keyword: String): String = tagPage("keyword", keyword)

def seriesPage(series: String): String = tagPage("series", series)

def sectionPage(section: String): String = tagPage("section", section)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h1>Inline Merchandising Slot</h1>
<li>keyword: <em>k</em></li>
<li>series: <em>se</em></li>
<li>contributor: <em>co</em></li>
<li>section: <em>s</em></li>
</ul>
</li>
</ol>
Expand Down Expand Up @@ -76,4 +77,13 @@ <h2>Line Items</h2>
</tbody>
</table>
}
<h2>Targeted Sections</h2>
@if(report.targetedTags.sections.isEmpty) {<p>None</p>} else {
<ol>
@for(section <- report.targetedTags.sections) {
<li style="font-size : large"><a href="@CapiLink.sectionPage(section)">@section</a></li>
}
</ol>
}

}
4 changes: 4 additions & 0 deletions common/app/common/dfp/DfpData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ case class CustomTarget(name: String, op: String, values: Seq[String]) {
val isSeriesTag = isPositive("se")
val isContributorTag = isPositive("co")
val isEditionTag = isPositive("edition")
val isSectionTag = isPositive("s")
}

object CustomTarget {
Expand All @@ -105,6 +106,7 @@ case class CustomTargetSet(op: String, targets: Seq[CustomTarget]) {
val inlineMerchandisingTargetedKeywords = filterTags(tag => tag.isKeywordTag)(_.isInlineMerchandisingSlot)
val inlineMerchandisingTargetedSeries = filterTags(tag => tag.isSeriesTag)(_.isInlineMerchandisingSlot)
val inlineMerchandisingTargetedContributors = filterTags(tag => tag.isContributorTag)(_.isInlineMerchandisingSlot)
val inlineMerchandisingTargetedSections = filterTags(tag => tag.isSectionTag)(_.isInlineMerchandisingSlot)

val highMerchandisingTargets =
filterTags(tag => tag.isKeywordTag || tag.isSeriesTag || tag.isContributorTag)(_.isHighMerchandisingSlot)
Expand Down Expand Up @@ -249,6 +251,8 @@ case class GuLineItem(
targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedSeries).distinct
val inlineMerchandisingTargetedContributors: Seq[String] =
targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedContributors).distinct
val inlineMerchandisingTargetedSections: Seq[String] =
targeting.customTargetSets.flatMap(_.inlineMerchandisingTargetedSections).distinct

val highMerchandisingTargets: Seq[String] = targeting.customTargetSets.flatMap(_.highMerchandisingTargets).distinct

Expand Down
5 changes: 4 additions & 1 deletion common/app/common/dfp/TagSponsorship.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object InlineMerchandisingTagSet {
"keywords" -> tagSet.keywords,
"series" -> tagSet.series,
"contributors" -> tagSet.contributors,
"sections" -> tagSet.sections,
)
}

Expand All @@ -22,6 +23,7 @@ case class InlineMerchandisingTagSet(
keywords: Set[String] = Set.empty,
series: Set[String] = Set.empty,
contributors: Set[String] = Set.empty,
sections: Set[String] = Set.empty,
) {

private def hasTagId(tags: Set[String], tagId: String): Boolean =
Expand All @@ -34,10 +36,11 @@ case class InlineMerchandisingTagSet(
case "Keyword" => hasTagId(keywords, tag.id)
case "Series" => hasTagId(series, tag.id)
case "Contributor" => hasTagId(contributors, tag.id)
case "Section" => hasTagId(sections, tag.id)
case _ => false
}

def nonEmpty: Boolean = keywords.nonEmpty || series.nonEmpty || contributors.nonEmpty
def nonEmpty: Boolean = keywords.nonEmpty || series.nonEmpty || contributors.nonEmpty || sections.nonEmpty
}

object InlineMerchandisingLineItem {
Expand Down

0 comments on commit b7a8bc5

Please sign in to comment.