Skip to content

Commit

Permalink
Use tone for Inline Merchandise
Browse files Browse the repository at this point in the history
  • Loading branch information
domlander committed Mar 27, 2024
1 parent b7a8bc5 commit 565937a
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 @@ -30,6 +30,7 @@ case class DfpDataExtractor(lineItems: Seq[GuLineItem], invalidLineItems: Seq[Gu
series = soFar.series ++ lineItem.inlineMerchandisingTargetedSeries,
contributors = soFar.contributors ++ lineItem.inlineMerchandisingTargetedContributors,
sections = soFar.sections ++ lineItem.inlineMerchandisingTargetedSections,
tones = soFar.tones ++ lineItem.inlineMerchandisingTargetedTones,
)
}
}
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 @@ -39,4 +39,6 @@ object CapiLink {
def seriesPage(series: String): String = tagPage("series", series)

def sectionPage(section: String): String = tagPage("section", section)

def tonePage(tone: String): String = tagPage("tone", tone)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1>Inline Merchandising Slot</h1>
<li>series: <em>se</em></li>
<li>contributor: <em>co</em></li>
<li>section: <em>s</em></li>
<li>tone: <em>tn</em></li>
</ul>
</li>
</ol>
Expand Down Expand Up @@ -86,4 +87,12 @@ <h2>Targeted Sections</h2>
</ol>
}

<h2>Targeted Tones</h2>
@if(report.targetedTags.tones.isEmpty) {<p>None</p>} else {
<ol>
@for(tone <- report.targetedTags.tones) {
<li style="font-size : large"><a href="@CapiLink.tonePage(tone)">@tone</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 @@ -87,6 +87,7 @@ case class CustomTarget(name: String, op: String, values: Seq[String]) {
val isContributorTag = isPositive("co")
val isEditionTag = isPositive("edition")
val isSectionTag = isPositive("s")
val isToneTag = isPositive("tn")
}

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

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

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

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

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

private def hasTagId(tags: Set[String], tagId: String): Boolean =
Expand All @@ -37,10 +39,12 @@ case class InlineMerchandisingTagSet(
case "Series" => hasTagId(series, tag.id)
case "Contributor" => hasTagId(contributors, tag.id)
case "Section" => hasTagId(sections, tag.id)
case "Tone" => hasTagId(tones, tag.id)
case _ => false
}

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

object InlineMerchandisingLineItem {
Expand Down

0 comments on commit 565937a

Please sign in to comment.