From b7a8bc577bfc7b5b7b0edb5e6eacc5b15cb18a55 Mon Sep 17 00:00:00 2001 From: Simon Byford Date: Fri, 24 Mar 2023 16:36:36 +0000 Subject: [PATCH] Add support for section (`s`) in `im` targeting --- admin/app/dfp/DfpDataExtractor.scala | 1 + admin/app/tools/DfpLink.scala | 2 ++ .../inlineMerchandisingTargetedTags.scala.html | 10 ++++++++++ common/app/common/dfp/DfpData.scala | 4 ++++ common/app/common/dfp/TagSponsorship.scala | 5 ++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/admin/app/dfp/DfpDataExtractor.scala b/admin/app/dfp/DfpDataExtractor.scala index 209104033ad6..5e782b083d8a 100644 --- a/admin/app/dfp/DfpDataExtractor.scala +++ b/admin/app/dfp/DfpDataExtractor.scala @@ -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, ) } } diff --git a/admin/app/tools/DfpLink.scala b/admin/app/tools/DfpLink.scala index 419c386f347f..f7f4e680d14a 100644 --- a/admin/app/tools/DfpLink.scala +++ b/admin/app/tools/DfpLink.scala @@ -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) } diff --git a/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html b/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html index 422338cb7307..2d7eb75a8812 100644 --- a/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html +++ b/admin/app/views/commercial/inlineMerchandisingTargetedTags.scala.html @@ -19,6 +19,7 @@

Inline Merchandising Slot

  • keyword: k
  • series: se
  • contributor: co
  • +
  • section: s
  • @@ -76,4 +77,13 @@

    Line Items

    } +

    Targeted Sections

    + @if(report.targetedTags.sections.isEmpty) {

    None

    } else { +
      + @for(section <- report.targetedTags.sections) { +
    1. @section
    2. + } +
    + } + } diff --git a/common/app/common/dfp/DfpData.scala b/common/app/common/dfp/DfpData.scala index 8f1a40a78f8f..765dabd9e226 100644 --- a/common/app/common/dfp/DfpData.scala +++ b/common/app/common/dfp/DfpData.scala @@ -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 { @@ -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) @@ -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 diff --git a/common/app/common/dfp/TagSponsorship.scala b/common/app/common/dfp/TagSponsorship.scala index 5fd0c31f21c7..ec13f08c6b90 100644 --- a/common/app/common/dfp/TagSponsorship.scala +++ b/common/app/common/dfp/TagSponsorship.scala @@ -13,6 +13,7 @@ object InlineMerchandisingTagSet { "keywords" -> tagSet.keywords, "series" -> tagSet.series, "contributors" -> tagSet.contributors, + "sections" -> tagSet.sections, ) } @@ -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 = @@ -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 {