Skip to content

Commit

Permalink
Remove affiliates cutoff date logic
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-imber committed May 21, 2024
1 parent ffd0f59 commit 3e9c079
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 36 deletions.
1 change: 0 additions & 1 deletion applications/app/views/fragments/galleryBody.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
defaultOffTags = Configuration.affiliateLinks.defaultOffTags,
alwaysOffTags = Configuration.affiliateLinks.alwaysOffTags,
tagPaths = page.gallery.content.tags.tags.map(_.id),
firstPublishedDate = page.gallery.content.fields.firstPublicationDate,
)
)

Expand Down
1 change: 0 additions & 1 deletion applications/app/views/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ object GalleryCaptionCleaners {
page.gallery.content.fields.showAffiliateLinks,
appendDisclaimer = Some(isFirstRow && page.item.lightbox.containsAffiliateableLinks),
tags = page.gallery.content.tags.tags.map(_.id),
page.gallery.content.fields.firstPublicationDate,
),
)

Expand Down
1 change: 0 additions & 1 deletion article/app/views/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ object BodyProcessor {
sectionId = article.content.metadata.sectionId,
showAffiliateLinks = article.content.fields.showAffiliateLinks,
tags = article.content.tags.tags.map(_.id),
publishedDate = article.content.fields.firstPublicationDate,
),
) ++
ListIf(true)(VideoEmbedCleaner(article))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ object DotcomRenderingUtils {
defaultOffTags = Configuration.affiliateLinks.defaultOffTags,
alwaysOffTags = Configuration.affiliateLinks.alwaysOffTags,
tagPaths = content.content.tags.tags.map(_.id),
firstPublishedDate = content.content.fields.firstPublicationDate,
)
} else false
} else false
Expand Down
13 changes: 2 additions & 11 deletions common/app/views/support/HtmlCleaner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,6 @@ case class AffiliateLinksCleaner(
showAffiliateLinks: Option[Boolean],
appendDisclaimer: Option[Boolean] = None,
tags: List[String],
publishedDate: Option[DateTime],
) extends HtmlCleaner
with GuLogging {

Expand All @@ -885,7 +884,6 @@ case class AffiliateLinksCleaner(
defaultOffTags,
alwaysOffTags,
tags,
publishedDate,
)
) {
AffiliateLinksCleaner.replaceLinksInHtml(document, pageUrl, skimlinksId)
Expand Down Expand Up @@ -940,17 +938,10 @@ object AffiliateLinksCleaner {
defaultOffTags: Set[String],
alwaysOffTags: Set[String],
tagPaths: List[String],
firstPublishedDate: Option[DateTime],
): Boolean = {
val publishedCutOffDate = new DateTime(2020, 8, 14, 0, 0)

// Never include affiliate links if it is tagged with an always off tag, or if it was published before our cut off date.
// The cut off date is temporary while we are working on improving the compliance of affiliate links.
if (
!contentHasAlwaysOffTag(tagPaths, alwaysOffTags) && firstPublishedDate.exists(
_.isBefore(publishedCutOffDate),
)
) {
// Never include affiliate links if it is tagged with an always off tag
if (!contentHasAlwaysOffTag(tagPaths, alwaysOffTags)) {
if (showAffiliateLinks.isDefined) {
showAffiliateLinks.contains(true)
} else {
Expand Down
21 changes: 0 additions & 21 deletions common/test/views/support/cleaner/AffiliateLinksCleanerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {

"shouldAddAffiliateLinks" should "correctly determine when to add affiliate links" in {
val supportedSections = Set("film", "books", "fashion")
val oldPublishedDate = Some(new DateTime(2020, 8, 13, 0, 0))
val newPublishedDate = Some(new DateTime(2020, 8, 15, 0, 0))

shouldAddAffiliateLinks(
switchedOn = false,
Expand All @@ -28,7 +26,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set.empty,
List.empty,
oldPublishedDate,
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -38,7 +35,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set.empty,
List.empty,
oldPublishedDate,
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -48,7 +44,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set.empty,
List.empty,
oldPublishedDate,
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -58,7 +53,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set.empty,
List.empty,
oldPublishedDate,
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -68,7 +62,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set("bereavement"),
Set.empty,
List("bereavement"),
oldPublishedDate,
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -78,7 +71,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set("bereavement"),
Set.empty,
List("tech"),
oldPublishedDate,
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -88,7 +80,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set("bereavement"),
Set.empty,
List("tech"),
oldPublishedDate,
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -98,7 +89,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set("bereavement"),
List("bereavement"),
oldPublishedDate,
) should be(false)
shouldAddAffiliateLinks(
switchedOn = true,
Expand All @@ -108,17 +98,6 @@ class AffiliateLinksCleanerTest extends AnyFlatSpec with Matchers {
Set.empty,
Set("bereavement"),
List("tech"),
oldPublishedDate,
) should be(true)
shouldAddAffiliateLinks(
switchedOn = true,
"film",
None,
supportedSections,
Set.empty,
Set.empty,
List.empty,
newPublishedDate,
) should be(true)
}
}

0 comments on commit 3e9c079

Please sign in to comment.