Skip to content

Commit

Permalink
Merge branch 'main' into dina/prepare-code-to-remove-ga
Browse files Browse the repository at this point in the history
  • Loading branch information
deedeeh authored Jun 3, 2024
2 parents 40ed524 + 31dd5a9 commit 4e8e463
Show file tree
Hide file tree
Showing 31 changed files with 128 additions and 123 deletions.
2 changes: 1 addition & 1 deletion admin/app/dfp/AdUnitAgent.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import common.dfp.GuAdUnit
import conf.Configuration
import ApiHelper.toSeq
Expand Down
2 changes: 1 addition & 1 deletion admin/app/dfp/ApiHelper.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405._
import common.GuLogging
import org.joda.time.{DateTime => JodaDateTime, DateTimeZone}

Expand Down
4 changes: 2 additions & 2 deletions admin/app/dfp/CustomFieldAgent.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.v202308.{CustomFieldValue, LineItem, TextValue}
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import com.google.api.ads.admanager.axis.v202405.{CustomFieldValue, LineItem, TextValue}
import common.dfp.GuCustomField
import concurrent.BlockingOperations

Expand Down
4 changes: 2 additions & 2 deletions admin/app/dfp/CustomTargetingAgent.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.v202308.{CustomTargetingKey, CustomTargetingValue}
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import com.google.api.ads.admanager.axis.v202405.{CustomTargetingKey, CustomTargetingValue}
import common.GuLogging
import common.dfp.{GuCustomTargeting, GuCustomTargetingValue}
import concurrent.BlockingOperations
Expand Down
2 changes: 1 addition & 1 deletion admin/app/dfp/DataMapper.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405._
import common.dfp._
import dfp.ApiHelper.{isPageSkin, optJavaInt, toJodaTime, toSeq}

Expand Down
2 changes: 1 addition & 1 deletion admin/app/dfp/DataValidation.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405._
import common.dfp._
import dfp.ApiHelper.toSeq

Expand Down
4 changes: 2 additions & 2 deletions admin/app/dfp/DfpApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dfp

// StatementBuilder query language is PQL defined here:
// https://developers.google.com/ad-manager/api/pqlreference
import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import com.google.api.ads.admanager.axis.v202405._
import com.madgag.scala.collection.decorators.MapDecorator
import common.GuLogging
import common.dfp._
Expand Down
2 changes: 1 addition & 1 deletion admin/app/dfp/PlacementAgent.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import common.dfp.GuAdUnit
import concurrent.BlockingOperations

Expand Down
6 changes: 3 additions & 3 deletions admin/app/dfp/Reader.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder.SUGGESTED_PAGE_LIMIT
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder.SUGGESTED_PAGE_LIMIT
import com.google.api.ads.admanager.axis.v202405._

import scala.annotation.tailrec

Expand Down
2 changes: 1 addition & 1 deletion admin/app/dfp/ServicesWrapper.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dfp

import com.google.api.ads.admanager.axis.factory.AdManagerServices
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405._
import com.google.api.ads.admanager.lib.client.AdManagerSession

private[dfp] class ServicesWrapper(session: AdManagerSession) {
Expand Down
4 changes: 2 additions & 2 deletions admin/app/dfp/SessionLogger.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import com.google.api.ads.admanager.axis.v202405._
import common.GuLogging

import scala.util.control.NonFatal
Expand Down
4 changes: 2 additions & 2 deletions admin/app/dfp/SessionWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dfp

import com.google.api.ads.common.lib.auth.OfflineCredentials
import com.google.api.ads.common.lib.auth.OfflineCredentials.Api
import com.google.api.ads.admanager.axis.utils.v202308.{ReportDownloader, StatementBuilder}
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.utils.v202405.{ReportDownloader, StatementBuilder}
import com.google.api.ads.admanager.axis.v202405._
import com.google.api.ads.admanager.lib.client.AdManagerSession
import com.google.common.io.CharSource
import common.GuLogging
Expand Down
8 changes: 4 additions & 4 deletions admin/app/jobs/CommercialDfpReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package jobs
import java.time.{LocalDate, LocalDateTime}

import app.LifecycleComponent
import com.google.api.ads.admanager.axis.v202308.Column.{AD_SERVER_IMPRESSIONS, AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}
import com.google.api.ads.admanager.axis.v202308.DateRangeType.CUSTOM_DATE
import com.google.api.ads.admanager.axis.v202308.Dimension.{CUSTOM_CRITERIA, DATE}
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405.Column.{AD_SERVER_IMPRESSIONS, AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM}
import com.google.api.ads.admanager.axis.v202405.DateRangeType.CUSTOM_DATE
import com.google.api.ads.admanager.axis.v202405.Dimension.{CUSTOM_CRITERIA, DATE}
import com.google.api.ads.admanager.axis.v202405._
import common.{PekkoAsync, Box, JobScheduler, GuLogging}
import dfp.DfpApi
import play.api.inject.ApplicationLifecycle
Expand Down
2 changes: 1 addition & 1 deletion admin/app/jobs/RefreshFrontsJob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object LowFrequency extends FrontType
object StandardFrequency extends FrontType
object HighFrequency extends FrontType {
def highFrequencyPaths: List[String] =
List("uk", "us", "au", "uk/sport", "us/sport", "au/sport")
List("uk", "us", "au", "europe", "international", "uk/sport", "us/sport", "au/sport")
}

case class CronUpdate(path: String, frontType: FrontType)
Expand Down
2 changes: 1 addition & 1 deletion admin/test/dfp/DfpApiValidationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dfp

import concurrent.BlockingOperations
import common.dfp.{GuAdUnit, GuLineItem, GuTargeting, Sponsorship}
import com.google.api.ads.admanager.axis.v202308._
import com.google.api.ads.admanager.axis.v202405._
import org.joda.time.DateTime
import org.apache.pekko.actor.ActorSystem
import org.scalatest.flatspec.AnyFlatSpec
Expand Down
2 changes: 1 addition & 1 deletion admin/test/dfp/ReaderTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dfp

import com.google.api.ads.admanager.axis.utils.v202308.StatementBuilder
import com.google.api.ads.admanager.axis.utils.v202405.StatementBuilder
import dfp.Reader.read
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
Expand Down
17 changes: 8 additions & 9 deletions applications/app/services/TagPagePicker.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package services.dotcomrendering

import common.GuLogging
import experiments.{ActiveExperiments, DCRTagPages}
import conf.switches.Switches.DCRTagPages
import implicits.Requests._
import model.TagCombiner
import play.api.mvc.RequestHeader
Expand All @@ -10,7 +10,7 @@ import services.IndexPage
object TagPagePicker extends GuLogging {

def getTier(tagPage: IndexPage)(implicit request: RequestHeader): RenderType = {
lazy val participatingInTest = ActiveExperiments.isParticipating(DCRTagPages)
lazy val isSwitchedOn = DCRTagPages.isSwitchedOn;

val checks = dcrChecks(tagPage)

Expand All @@ -19,11 +19,11 @@ object TagPagePicker extends GuLogging {
request.isJson,
request.forceDCROff,
request.forceDCR,
participatingInTest,
isSwitchedOn,
dcrCouldRender(checks),
)

logTier(tagPage, participatingInTest, dcrCouldRender(checks), checks, tier)
logTier(tagPage, isSwitchedOn, dcrCouldRender(checks), checks, tier)

tier
}
Expand All @@ -45,7 +45,7 @@ object TagPagePicker extends GuLogging {
isJson: Boolean,
forceDCROff: Boolean,
forceDCR: Boolean,
participatingInTest: Boolean,
isSwitchedOn: Boolean,
dcrCouldRender: Boolean,
): RenderType = {
if (isRss) LocalRender
Expand All @@ -55,13 +55,13 @@ object TagPagePicker extends GuLogging {
else LocalRender
} else if (forceDCROff) LocalRender
else if (forceDCR) RemoteRender
else if (dcrCouldRender && participatingInTest) RemoteRender
else if (dcrCouldRender && isSwitchedOn) RemoteRender
else LocalRender
}

private def logTier(
tagPage: IndexPage,
participatingInTest: Boolean,
isSwitchedOn: Boolean,
dcrCouldRender: Boolean,
checks: Map[String, Boolean],
tier: RenderType,
Expand All @@ -73,8 +73,7 @@ object TagPagePicker extends GuLogging {
}
val properties =
Map(
"participatingInTest" -> participatingInTest.toString,
"testPercentage" -> DCRTagPages.participationGroup.percentage,
"isSwitchedOn" -> isSwitchedOn.toString,
"dcrCouldRender" -> dcrCouldRender.toString,
"isTagPage" -> "true",
"tier" -> tierReadable,
Expand Down
4 changes: 3 additions & 1 deletion applications/test/AllIndexControllerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ import play.api.test.Helpers._

it should "correctly serve all pages for `default editionalised sections` in the International edition" in {
val result =
allIndexController.all("commentisfree")(TestRequest("/commentisfree/all").withHeaders("X-Gu-Edition" -> "INT"))
allIndexController.all("commentisfree")(
TestRequest("/commentisfree/all?dcr=false").withHeaders("X-Gu-Edition" -> "INT"),
)
status(result) should be(OK)
}

Expand Down
6 changes: 3 additions & 3 deletions applications/test/IndexControllerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import play.api.libs.ws.WSClient
)

"Index Controller" should "200 when content type is front" in {
val result = indexController.render(section)(TestRequest(s"/$section"))
val result = indexController.render(section)(TestRequest(s"/$section?dcr=false"))
status(result) should be(200)
}

Expand Down Expand Up @@ -112,14 +112,14 @@ import play.api.libs.ws.WSClient
}

it should "not accidentally truncate tags that contain valid strings that are also editions" in {
val request = FakeRequest(GET, "/uk/london?page=2")
val request = FakeRequest(GET, "/uk/london?page=2&dcr=false")
val result = indexController.render("uk/london")(request)

status(result) should be(200)
}

it should "not add editions to section tags" in {
val request = FakeRequest(GET, "/sport?page=2")
val request = FakeRequest(GET, "/sport?page=2&dcr=false")
val result = indexController.render("sport")(request)

status(result) should be(200)
Expand Down
12 changes: 6 additions & 6 deletions applications/test/IndexMetaDataTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,32 @@ import play.api.test.Helpers._
)

it should "Include organisation metadata" in {
val result = indexController.render(articleUrl)(TestRequest(articleUrl))
val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false"))
MetaDataMatcher.ensureOrganisation(result)
}

it should "Include webpage metadata" in {
val result = indexController.render(articleUrl)(TestRequest(articleUrl))
val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false"))
MetaDataMatcher.ensureWebPage(result, articleUrl)
}

it should "Include app deep link" in {
val result = indexController.render(articleUrl)(TestRequest(articleUrl))
val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false"))
MetaDataMatcher.ensureDeepLink(result)
}

it should "Not include app deep link on the crosswords index" in {
val result = indexController.render(crosswordsUrl)(TestRequest(crosswordsUrl))
val result = indexController.render(crosswordsUrl)(TestRequest(s"$crosswordsUrl?dcr=false"))
MetaDataMatcher.ensureNoDeepLink(result)
}

it should "not include webpage metadata on the crossword index" in {
val result = indexController.render(crosswordsUrl)(TestRequest(crosswordsUrl))
val result = indexController.render(crosswordsUrl)(TestRequest(s"$crosswordsUrl?dcr=false"))
MetaDataMatcher.ensureNoIosUrl(result)
}

it should "Include item list metadata" in {
val result = indexController.render(articleUrl)(TestRequest(articleUrl))
val result = indexController.render(articleUrl)(TestRequest(s"$articleUrl?dcr=false"))
val body = Jsoup.parseBodyFragment(contentAsString(result))
status(result) should be(200)

Expand Down
29 changes: 15 additions & 14 deletions applications/test/SectionTemplateTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ import scala.jdk.CollectionConverters._

@DoNotDiscover class SectionTemplateTest extends AnyFlatSpec with Matchers with ConfiguredTestSuite {

it should "render front title" in goTo("/uk-news") { browser =>
it should "render front title" in goTo("/uk-news?dcr=false") { browser =>
browser.el("[data-test-id=header-title]").text should be("UK news")
}

it should "add alternate pages to editionalised sections for /uk/culture" in goTo("/uk/culture") { browser =>
val alternateLinks = getAlternateLinks(browser)
alternateLinks.size should be(3)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/us/culture" && link.attribute("hreflang") == "en-US",
) should be(true)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/au/culture" && link.attribute("hreflang") == "en-AU",
) should be(true)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/uk/culture" && link.attribute("hreflang") == "en-GB",
) should be(true)
it should "add alternate pages to editionalised sections for /uk/culture" in goTo("/uk/culture?dcr=false") {
browser =>
val alternateLinks = getAlternateLinks(browser)
alternateLinks.size should be(3)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/us/culture" && link.attribute("hreflang") == "en-US",
) should be(true)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/au/culture" && link.attribute("hreflang") == "en-AU",
) should be(true)
alternateLinks.exists(link =>
toPath(link.attribute("href")) == "/uk/culture" && link.attribute("hreflang") == "en-GB",
) should be(true)

}

Expand All @@ -40,7 +41,7 @@ import scala.jdk.CollectionConverters._
})
}

it should "not add alternate pages to non editionalised sections" in goTo("/books") { browser =>
it should "not add alternate pages to non editionalised sections" in goTo("/books?dcr=false") { browser =>
val alternateLinks = getAlternateLinks(browser)
alternateLinks should be(empty)
}
Expand Down
10 changes: 5 additions & 5 deletions applications/test/TagFeatureTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.scalatest.matchers.should.Matchers

Given("I visit a tag page")

goTo("/technology/askjack") { browser =>
goTo("/technology/askjack?dcr=false") { browser =>
val trails = browser.$(".fc-item__container")
trails.asScala.length should be(IndexPagePagination.pageSize)
}
Expand All @@ -31,7 +31,7 @@ import org.scalatest.matchers.should.Matchers
Given("I visit the 'Jemima Kiss' contributor page")
Switches.ImageServerSwitch.switchOn()

goTo("/profile/jemimakiss") { browser =>
goTo("/profile/jemimakiss?dcr=false") { browser =>
Then("I should see her profile image")
val profileImage = browser.el("[data-test-id=header-image]")
profileImage.attribute("src") should include(s"42593747/Jemima-Kiss.jpg")
Expand All @@ -41,7 +41,7 @@ import org.scalatest.matchers.should.Matchers
Scenario("Should not not display profiles where they don't exist") {

Given("I visit the 'Sam Jones' contributor page")
goTo("/profile/samjones") { browser =>
goTo("/profile/samjones?dcr=false") { browser =>
Then("I should not see her profile image")
val profileImages = browser.find(".profile__img img")
profileImages.asScala.length should be(0)
Expand All @@ -65,7 +65,7 @@ import org.scalatest.matchers.should.Matchers

Given("I visit the 'Cycling' tag page")

goTo("/sport/cycling") { browser =>
goTo("/sport/cycling?dcr=false") { browser =>
import browser._

val cardsOnFirstPage = browser.find("[data-test-id=facia-card]")
Expand Down Expand Up @@ -96,7 +96,7 @@ import org.scalatest.matchers.should.Matchers

Given("I visit page 2 of the 'Cycling' tag page")

goTo("/sport/cycling?page=2") { browser =>
goTo("/sport/cycling?page=2&dcr=false") { browser =>
import browser._

val cardsOnNextPage = browser.find("[data-test-id=facia-card]")
Expand Down
2 changes: 1 addition & 1 deletion applications/test/TagTemplateTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest.matchers.should.Matchers

@DoNotDiscover class TagTemplateTest extends AnyFlatSpec with Matchers with ConfiguredTestSuite {

it should "render tag headline" in goTo("/world/turkey") { browser =>
it should "render tag headline" in goTo("/world/turkey?dcr=false") { browser =>
browser.el("[data-test-id=header-title]").text should be("Turkey")
}
}
Loading

0 comments on commit 4e8e463

Please sign in to comment.