Skip to content

Commit

Permalink
Remove High Merchandising from Targeting section in admin commercial …
Browse files Browse the repository at this point in the history
…tools
  • Loading branch information
emma-imber committed Oct 9, 2024
1 parent 7bfb7e7 commit 401ad66
Show file tree
Hide file tree
Showing 15 changed files with 4 additions and 375 deletions.
12 changes: 1 addition & 11 deletions admin/app/controllers/admin/CommercialController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ class CommercialController(
NoCache(Ok(views.html.commercial.surgingpages(surging)))
}

def renderHighMerchandisingTargetedTags: Action[AnyContent] =
Action { implicit request =>
val report = Store.getDfpHighMerchandisingTargetedTagsReport()
NoCache(Ok(views.html.commercial.highMerchandisingTargetedTags(report)))
}

def renderLiveBlogTopSponsorships: Action[AnyContent] =
Action { implicit request =>
val report = Store.getDfpLiveBlogTagsReport()
Expand Down Expand Up @@ -185,7 +179,6 @@ class CommercialController(

// Sort line items into groups where possible, and bucket everything else.
val pageskins = invalidItemsExtractor.pageSkinSponsorships
val highMerch = invalidItemsExtractor.targetedHighMerchandisingLineItems.items

val groupedItems = invalidLineItems.groupBy {
case item if sonobiOrderIds.contains(item.orderId) => "sonobi"
Expand All @@ -196,14 +189,11 @@ class CommercialController(
val invalidItemsMap = GuLineItem.asMap(invalidLineItems)

val unidentifiedLineItems =
invalidItemsMap.keySet -- pageskins.map(_.lineItemId) -- highMerch.map(
_.id,
) -- sonobiItems.map(_.id)
invalidItemsMap.keySet -- pageskins.map(_.lineItemId) -- sonobiItems.map(_.id)

Ok(
views.html.commercial.invalidLineItems(
pageskins,
highMerch,
sonobiItems,
unidentifiedLineItems.toSeq.map(invalidItemsMap),
),
Expand Down
5 changes: 0 additions & 5 deletions admin/app/dfp/DfpDataCacheJob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ class DfpDataCacheJob(
if (data.hasValidLineItems) {
val now = printLondonTime(DateTime.now())

val targetedHighMerchandisingLineItems = data.targetedHighMerchandisingLineItems
Store.putHighMerchandisingSponsorships(
stringify(toJson(HighMerchandisingTargetedTagsReport(now, targetedHighMerchandisingLineItems))),
)

val pageSkinSponsorships = data.pageSkinSponsorships
Store.putDfpPageSkinAdUnits(stringify(toJson(PageSkinSponsorshipReport(now, pageSkinSponsorships))))

Expand Down
17 changes: 0 additions & 17 deletions admin/app/dfp/DfpDataExtractor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,6 @@ case class DfpDataExtractor(lineItems: Seq[GuLineItem], invalidLineItems: Seq[Gu
}
}

val targetedHighMerchandisingLineItems: HighMerchandisingLineItems = {
val highMerchLineItems = lineItems
.filter(_.targetsHighMerchandising)
.foldLeft(Seq.empty[HighMerchandisingLineItem]) { (soFar, lineItem) =>
soFar :+ HighMerchandisingLineItem(
name = lineItem.name,
id = lineItem.id,
tags = lineItem.highMerchandisingTargets,
adUnitsIncluded = lineItem.targeting.adUnitsIncluded,
adUnitsExcluded = lineItem.targeting.adUnitsExcluded,
customTargetSet = lineItem.targeting.customTargetSets,
)
}

HighMerchandisingLineItems(items = highMerchLineItems)
}

val pageSkinSponsorships: Seq[PageSkinSponsorship] = {
lineItems withFilter { lineItem =>
lineItem.isPageSkin && lineItem.isCurrent
Expand Down
6 changes: 0 additions & 6 deletions admin/app/tools/Store.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ trait Store extends GuLogging with Dates {
def putSurveySponsorships(adUnitJson: String): Unit = {
S3.putPublic(dfpSurveySponsorshipDataKey, adUnitJson, defaultJsonEncoding)
}
def putHighMerchandisingSponsorships(keywordsJson: String): Unit = {
S3.putPublic(dfpHighMerchandisingTagsDataKey, keywordsJson, defaultJsonEncoding)
}
def putDfpPageSkinAdUnits(adUnitJson: String): Unit = {
S3.putPublic(dfpPageSkinnedAdUnitsKey, adUnitJson, defaultJsonEncoding)
}
Expand Down Expand Up @@ -76,9 +73,6 @@ trait Store extends GuLogging with Dates {
Nil,
)
}
def getDfpHighMerchandisingTargetedTagsReport(): HighMerchandisingTargetedTagsReport = {
S3.get(dfpHighMerchandisingTagsDataKey) flatMap (HighMerchandisingTargetedTagsReportParser(_))
} getOrElse HighMerchandisingTargetedTagsReport(now, HighMerchandisingLineItems(items = List.empty))

def getDfpLineItemsReport(): LineItemReport = {
val maybeLineItems = for {
Expand Down
1 change: 0 additions & 1 deletion admin/app/views/commercial/commercialMenu.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ <h3>Targeting</h3>
<ul>
<li><a href="@controllers.admin.routes.CommercialController.renderSpecialAdUnits()">Special Ad Units</a></li>
<li><a href="https://tagmanager.gutools.co.uk/sponsorship">Sponsorships</a></li>
<li><a href="@controllers.admin.routes.CommercialController.renderHighMerchandisingTargetedTags()">High Merchandising Slot</a></li>
<li><a href="@controllers.admin.routes.CommercialController.renderLiveBlogTopSponsorships()">Live Blog Top Sponsorships</a></li>
<li><a href="@controllers.admin.routes.CommercialController.renderSurveySponsorships()">Survey Sponsorships</a></li>
<li><a href="@controllers.admin.routes.CommercialController.renderPageskins()">Pageskins</a></li>
Expand Down

This file was deleted.

26 changes: 2 additions & 24 deletions admin/app/views/commercial/invalidLineItems.scala.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@import tools.DfpLink
@import common.dfp.PageSkinSponsorship
@import common.dfp.{HighMerchandisingLineItem, GuLineItem}
@import common.dfp.{GuLineItem}

@(invalidPageskins: Seq[PageSkinSponsorship],
invalidHighMerchandising: Seq[HighMerchandisingLineItem],
sonobiItems: Seq[GuLineItem],
unknownInvalidLineItems: Seq[GuLineItem])(implicit request: RequestHeader, context: model.ApplicationContext)

Expand All @@ -20,7 +19,7 @@ <h1>Invalid Line Items</h1>
</p>

<p>
Use this page to diagnose issues with page skins, or high-merchandising items, or top slot takeovers.
Use this page to diagnose issues with page skins.
</p>

<h2>Invalid Page Skin Sponsorships</h2>
Expand All @@ -44,27 +43,6 @@ <h2>Invalid Page Skin Sponsorships</h2>
</table>
}

<h2>Invalid High-Merchandising Line Items</h2>

@if(invalidHighMerchandising.isEmpty) {<em>None</em>} else {
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th class="col-md-4">Line Item Name</th>
<th class="col-md-4">DFP link</th>
</tr>
</thead>
<tbody>
@for(invalidHighMerch <- invalidHighMerchandising) {
<tr>
<td>@{invalidHighMerch.name}</td>
<td><a target="_blank" href="@DfpLink.lineItem(invalidHighMerch.id)">@{invalidHighMerch.id}</a></td>
</tr>
}
</tbody>
</table>
}

<h2>Unidentified Line Items</h2>

<p>
Expand Down
1 change: 0 additions & 1 deletion admin/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ GET /commercial
GET /commercial/specialadunits controllers.admin.CommercialController.renderSpecialAdUnits()
GET /commercial/pageskins controllers.admin.CommercialController.renderPageskins()
GET /commercial/surging controllers.admin.CommercialController.renderSurgingContent()
GET /commercial/high-merchandising controllers.admin.CommercialController.renderHighMerchandisingTargetedTags()
GET /commercial/liveblog-top controllers.admin.CommercialController.renderLiveBlogTopSponsorships()
GET /commercial/survey controllers.admin.CommercialController.renderSurveySponsorships()
GET /commercial/templates controllers.admin.CommercialController.renderCreativeTemplates()
Expand Down
1 change: 0 additions & 1 deletion common/app/common/configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ class GuardianConfiguration extends GuLogging {
}

private lazy val dfpRoot = s"$commercialRoot/dfp"
lazy val dfpHighMerchandisingTagsDataKey = s"$dfpRoot/high-merchandising-tags.json"
lazy val dfpPageSkinnedAdUnitsKey = s"$dfpRoot/pageskinned-adunits-v9.json"
lazy val dfpLiveBlogTopSponsorshipDataKey = s"$dfpRoot/liveblog-top-sponsorships-v3.json"
lazy val dfpSurveySponsorshipDataKey = s"$dfpRoot/survey-sponsorships.json"
Expand Down
26 changes: 1 addition & 25 deletions common/app/common/dfp/DfpAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@ import services.S3
import scala.concurrent.ExecutionContext
import scala.io.Codec.UTF8

object DfpAgent
extends PageskinAdAgent
with LiveBlogTopSponsorshipAgent
with SurveySponsorshipAgent
with HighMerchandiseComponentAgent
with AdSlotAgent {
object DfpAgent extends PageskinAdAgent with LiveBlogTopSponsorshipAgent with SurveySponsorshipAgent with AdSlotAgent {

override protected val environmentIsProd: Boolean = environment.isProd

private lazy val targetedHighMerchandisingLineItemsAgent = Box[Seq[HighMerchandisingLineItem]](Seq.empty)
private lazy val liveblogTopSponsorshipAgent = Box[Seq[LiveBlogTopSponsorship]](Nil)
private lazy val surveyAdUnitAgent = Box[Seq[SurveySponsorship]](Nil)
private lazy val pageskinnedAdUnitAgent = Box[Seq[PageSkinSponsorship]](Nil)
private lazy val lineItemAgent = Box[Map[AdSlot, Seq[GuLineItem]]](Map.empty)
private lazy val takeoverWithEmptyMPUsAgent = Box[Seq[TakeoverWithEmptyMPUs]](Nil)
private lazy val nonRefreshableLineItemsAgent = Box[Seq[Long]](Nil)

protected def targetedHighMerchandisingLineItems: Seq[HighMerchandisingLineItem] =
targetedHighMerchandisingLineItemsAgent.get()
protected def pageSkinSponsorships: Seq[PageSkinSponsorship] = pageskinnedAdUnitAgent.get()
protected def liveBlogTopSponsorships: Seq[LiveBlogTopSponsorship] = liveblogTopSponsorshipAgent.get()
protected def surveySponsorships: Seq[SurveySponsorship] = surveyAdUnitAgent.get()
Expand Down Expand Up @@ -81,20 +73,6 @@ object DfpAgent
} yield lineItemIds) getOrElse Nil
}

def grabTargetedHighMerchandisingLineItemFromStore(): Seq[HighMerchandisingLineItem] = {
for {
jsonString <- stringFromS3(dfpHighMerchandisingTagsDataKey).toSeq
report <- HighMerchandisingTargetedTagsReportParser(jsonString).toSeq
lineItems <- report.lineItems.items
} yield lineItems
}

def updateTargetedHighMerchandisingLineItems(freshData: Seq[HighMerchandisingLineItem]): Unit = {
targetedHighMerchandisingLineItemsAgent send { oldData =>
if (freshData.nonEmpty) freshData else oldData
}
}

update(pageskinnedAdUnitAgent)(grabPageSkinSponsorshipsFromStore(dfpPageSkinnedAdUnitsKey))

update(nonRefreshableLineItemsAgent)(grabNonRefreshableLineItemIdsFromStore())
Expand All @@ -103,8 +81,6 @@ object DfpAgent

update(surveyAdUnitAgent)(grabSurveySponsorshipsFromStore())

updateTargetedHighMerchandisingLineItems(grabTargetedHighMerchandisingLineItemFromStore())

}

def refreshFaciaSpecificData()(implicit executionContext: ExecutionContext): Unit = {
Expand Down
16 changes: 0 additions & 16 deletions common/app/common/dfp/DfpData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ case class CustomTarget(name: String, op: String, values: Seq[String]) {
values.intersect(liveBlogTopSectionTargets).nonEmpty
}

val isHighMerchandisingSlot = isSlot("merchandising-high")

val isLiveblogTopSlot = isSlot("liveblog-top")

val isSurveySlot = isSlot("survey")
Expand Down Expand Up @@ -113,9 +111,6 @@ case class CustomTargetSet(op: String, targets: Seq[CustomTarget]) {
} else Nil
}

val highMerchandisingTargets =
filterTags(tag => tag.isKeywordTag || tag.isSeriesTag || tag.isContributorTag)(_.isHighMerchandisingSlot)

val liveblogTopTargetedSections = filterTags(_.isLiveBlogTopTargetedSection)(_.isLiveblogTopSlot)
}

Expand Down Expand Up @@ -252,20 +247,9 @@ case class GuLineItem(
val isExpiredRecently = isExpired && endTime.exists(_.isAfter(now.minusWeeks(1)))
val isExpiringSoon = !isExpired && endTime.exists(_.isBefore(now.plusMonths(1)))

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

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

val targetsHighMerchandising: Boolean = {
val targetSlotIsHighMerch = for {
targetSet <- targeting.customTargetSets
target <- targetSet.targets
if target.name == "slot" && target.values.contains("merchandising-high")
} yield target
targetSlotIsHighMerch.nonEmpty
}

val targetsLiveBlogTop: Boolean = {
val matchingLiveblogTargeting = for {
targetSet <- targeting.customTargetSets
Expand Down
13 changes: 0 additions & 13 deletions common/app/common/dfp/HighMerchandiseComponentAgent.scala

This file was deleted.

Loading

0 comments on commit 401ad66

Please sign in to comment.