Skip to content

Commit

Permalink
dont need lifecycle for parameter store
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Dec 3, 2024
1 parent 0361b2e commit 0088f55
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 70 deletions.
2 changes: 0 additions & 2 deletions article/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import app.{FrontendApplicationLoader, FrontendBuildInfo, FrontendComponents}
import com.softwaremill.macwire._
import common._
import common.dfp.DfpAgentLifecycle
import common.commercial.CommercialBundleUrlLifecycle
import concurrent.BlockingOperations
import conf.{CachedHealthCheckLifeCycle, Configuration}
import conf.switches.SwitchboardLifecycle
Expand Down Expand Up @@ -46,7 +45,6 @@ trait AppComponents extends FrontendComponents with ArticleControllers {
override lazy val lifecycleComponents = List(
wire[NewspaperBooksAndSectionsAutoRefresh],
wire[DfpAgentLifecycle],
wire[CommercialBundleUrlLifecycle],
wire[CloudWatchMetricsLifecycle],
wire[SurgingContentAgentLifecycle],
wire[SwitchboardLifecycle],
Expand Down
2 changes: 0 additions & 2 deletions commercial/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import commercial.model.merchandise.jobs.{Industries, JobsAgent}
import commercial.model.merchandise.travel.TravelOffersAgent
import common.CloudWatchMetricsLifecycle
import common.dfp.DfpAgentLifecycle
import common.commercial.CommercialBundleUrlLifecycle
import conf.switches.SwitchboardLifecycle
import conf.CachedHealthCheckLifeCycle
import contentapi.{CapiHttpClient, ContentApiClient, HttpClient}
Expand Down Expand Up @@ -56,7 +55,6 @@ trait AppComponents extends FrontendComponents with CommercialControllers with C
override lazy val lifecycleComponents = List(
wire[CommercialLifecycle],
wire[DfpAgentLifecycle],
wire[CommercialBundleUrlLifecycle],
wire[SwitchboardLifecycle],
wire[CloudWatchMetricsLifecycle],
wire[CachedHealthCheckLifeCycle],
Expand Down
29 changes: 29 additions & 0 deletions common/app/common/CommercialBundle.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package common

import scala.concurrent.duration._
import org.joda.time.Instant
import conf.Configuration

object CommercialBundle {
import GuardianConfiguration._

private var cachedBundlePath: String =
"test_commercial_bundles/" + configuration.getMandatoryStringProperty("commercial.bundlePath")
private var cachedTimestamp: Instant = Instant.now()
private val cacheDuration: FiniteDuration = 1.minute

private val assetHost = Configuration.assets.path

private def updateBundlePath(): Unit = {
cachedBundlePath = "test_commercial_bundles/" + configuration.getMandatoryStringProperty("commercial.bundlePath")
cachedTimestamp = Instant.now()
}

private def bundlePath: String = {
if (Instant.now().isAfter(cachedTimestamp.plus(cacheDuration.toMillis))) updateBundlePath()

cachedBundlePath
}

def getBundleUrl: String = s"$assetHost$bundlePath"
}
26 changes: 0 additions & 26 deletions common/app/common/commercial/CommercialBundleUrlAgent.scala

This file was deleted.

32 changes: 0 additions & 32 deletions common/app/common/commercial/CommercialBundleUrlLifecycle.scala

This file was deleted.

4 changes: 2 additions & 2 deletions common/app/views/support/JavaScriptPage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import model.IpsosTags.getScriptTag
import model.dotcomrendering.DotcomRenderingUtils.assetURL
import play.api.mvc.RequestHeader
import views.support.Commercial.isAdFree
import common.commercial.CommercialBundleUrlAgent
import common.CommercialBundle

object JavaScriptPage {

Expand Down Expand Up @@ -72,7 +72,7 @@ object JavaScriptPage {
val ipsos = if (page.metadata.isFront) getScriptTag(page.metadata.id) else getScriptTag(page.metadata.sectionId)

def commercialBundleUrl = JsString(
CommercialBundleUrlAgent.bundleUrl,
CommercialBundle.getBundleUrl,
)

javascriptConfig ++ config ++ commercialMetaData ++ journalismMetaData ++ Map(
Expand Down
2 changes: 0 additions & 2 deletions dev-build/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import cricket.conf.CricketLifecycle
import cricket.controllers.CricketControllers
import dev.DevAssetsController
import dfp.DfpDataCacheLifecycle
import common.commercial.CommercialBundleUrlLifecycle
import feed._
import football.controllers._
import http.{CorsHttpErrorHandler, DevBuildParametersHttpRequestHandler, DevFilters}
Expand Down Expand Up @@ -91,7 +90,6 @@ trait AppComponents
wire[OnwardJourneyLifecycle],
wire[CommercialLifecycle],
wire[DfpDataCacheLifecycle],
wire[CommercialBundleUrlLifecycle],
wire[FaciaDfpAgentLifecycle],
wire[ConfigAgentLifecycle],
wire[SurgingContentAgentLifecycle],
Expand Down
2 changes: 0 additions & 2 deletions facia/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import app.{FrontendApplicationLoader, FrontendBuildInfo, FrontendComponents}
import com.softwaremill.macwire._
import common._
import common.dfp.FaciaDfpAgentLifecycle
import common.commercial.CommercialBundleUrlLifecycle
import concurrent.BlockingOperations
import conf.switches.SwitchboardLifecycle
import conf.CachedHealthCheckLifeCycle
Expand Down Expand Up @@ -55,7 +54,6 @@ trait AppComponents extends FrontendComponents with FaciaControllers with FapiSe
wire[ConfigAgentLifecycle],
wire[CloudWatchMetricsLifecycle],
wire[FaciaDfpAgentLifecycle],
wire[CommercialBundleUrlLifecycle],
wire[SurgingContentAgentLifecycle],
wire[IndexListingsLifecycle],
wire[SwitchboardLifecycle],
Expand Down
2 changes: 0 additions & 2 deletions preview/app/AppLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import commercial.CommercialLifecycle
import commercial.controllers.CommercialControllers
import commercial.targeting.TargetingLifecycle
import common.dfp.FaciaDfpAgentLifecycle
import common.commercial.CommercialBundleUrlLifecycle
import common.{ApplicationMetrics, CloudWatchMetricsLifecycle, ContentApiMetrics, DCRMetrics}
import conf.switches.SwitchboardLifecycle
import conf.{CachedHealthCheckLifeCycle, FootballLifecycle}
Expand Down Expand Up @@ -54,7 +53,6 @@ trait PreviewLifecycleComponents
wire[OnwardJourneyLifecycle],
wire[ConfigAgentLifecycle],
wire[FaciaDfpAgentLifecycle],
wire[CommercialBundleUrlLifecycle],
wire[SwitchboardLifecycle],
wire[FootballLifecycle],
wire[CricketLifecycle],
Expand Down

0 comments on commit 0088f55

Please sign in to comment.