From a5e69b7c56afd98514cc518b134162953fee9cee Mon Sep 17 00:00:00 2001 From: Pete Smith Date: Wed, 30 Nov 2022 00:40:57 +1100 Subject: [PATCH] [PS] TAV-594 - Use new RDS db for ABP searches if enabled in config --- app/Module.scala | 12 +++++++++++- .../CIPPostgresABPAddressRepository.scala | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Module.scala b/app/Module.scala index c357667..24ff86e 100644 --- a/app/Module.scala +++ b/app/Module.scala @@ -56,9 +56,16 @@ class Module(environment: Environment, configuration: Configuration) extends Abs inMemoryABPAddressRepository: InMemoryABPAddressRepository): ABPAddressRepository = { val dbEnabled = isDbEnabled(configHelper) + val cipPaasDbEnabled = isCipPaasDbEnabled(configHelper) val repository: ABPAddressRepository = if (dbEnabled) { - val transactor = new TransactorProvider(configuration, applicationLifecycle).get(executionContext) + val transactor = if (cipPaasDbEnabled) { + new TransactorProvider(configuration, applicationLifecycle, "cip-address-lookup-rds").get(executionContext) + } + else { + new TransactorProvider(configuration, applicationLifecycle).get(executionContext) + } + new PostgresABPAddressRepository(transactor, rdsQueryConfig) } else { inMemoryABPAddressRepository @@ -98,6 +105,9 @@ class Module(environment: Environment, configuration: Configuration) extends Abs private def isDbEnabled(configHelper: ConfigHelper): Boolean = configHelper.getConfigString("address-lookup-rds.enabled").getOrElse("false").toBoolean + private def isCipPaasDbEnabled(configHelper: ConfigHelper): Boolean = + configHelper.getConfigString("cip-address-lookup-rds.enabled").getOrElse("false").toBoolean + @Provides @Singleton def providesReferenceData(configHelper: ConfigHelper): ReferenceData = diff --git a/app/repositories/CIPPostgresABPAddressRepository.scala b/app/repositories/CIPPostgresABPAddressRepository.scala index c689ca1..1d8d45b 100644 --- a/app/repositories/CIPPostgresABPAddressRepository.scala +++ b/app/repositories/CIPPostgresABPAddressRepository.scala @@ -17,7 +17,6 @@ package repositories import cats.effect.IO -import config.Capitalisation._ import doobie.Transactor import doobie.implicits._ import play.api.Logger