Skip to content

Commit

Permalink
Merge pull request #236 from hmrc/Tom/DLS-10604/implement-missing-ind…
Browse files Browse the repository at this point in the history
…exes-in-DocRefIdRepository

DLS-10604 - indexed "id" in DocRefIdRepository
  • Loading branch information
TomRafferty authored Jun 28, 2024
2 parents d75fa2f + 42fd008 commit 736436f
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/uk/gov/hmrc/cbcr/auth/CBCRAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package uk.gov.hmrc.cbcr.auth

import javax.inject.{Inject, Singleton}
import play.api.libs.json.JsValue
import play.api.mvc._
import uk.gov.hmrc.auth.core.AuthProvider.GovernmentGateway
import uk.gov.hmrc.auth.core._
import uk.gov.hmrc.auth.core.retrieve.v2.Retrievals.affinityGroup
import uk.gov.hmrc.play.http.HeaderCarrierConverter
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController
import uk.gov.hmrc.play.http.HeaderCarrierConverter

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
Expand Down
5 changes: 3 additions & 2 deletions app/uk/gov/hmrc/cbcr/connectors/EmailConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package uk.gov.hmrc.cbcr.connectors

import com.google.inject.ImplementedBy
import com.typesafe.config.Config
import javax.inject.{Inject, Singleton}
import play.api.Configuration
import uk.gov.hmrc.cbcr.models.Email
import uk.gov.hmrc.http.HttpReads.Implicits.readRaw
import uk.gov.hmrc.http.{HeaderCarrier, HttpClient, HttpPost, HttpResponse}

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}
import uk.gov.hmrc.http.HttpReads.Implicits.readRaw

@ImplementedBy(classOf[EmailConnectorImpl])
trait EmailConnector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package uk.gov.hmrc.cbcr.controllers

import javax.inject.{Inject, Singleton}
import play.api.mvc.ControllerComponents
import uk.gov.hmrc.cbcr.auth.CBCRAuth
import uk.gov.hmrc.cbcr.connectors.DESConnector
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext

@Singleton
Expand Down
3 changes: 2 additions & 1 deletion app/uk/gov/hmrc/cbcr/controllers/CBCREmailController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package uk.gov.hmrc.cbcr.controllers

import javax.inject.{Inject, Singleton}
import play.api.mvc.{ControllerComponents, Result}
import uk.gov.hmrc.cbcr.auth.CBCRAuth
import uk.gov.hmrc.cbcr.models.Email
import uk.gov.hmrc.cbcr.services.EmailService
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package uk.gov.hmrc.cbcr.controllers

import javax.inject.{Inject, Singleton}
import play.api.mvc.ControllerComponents
import uk.gov.hmrc.cbcr.auth.CBCRAuth
import uk.gov.hmrc.cbcr.models.MessageRefId
import uk.gov.hmrc.cbcr.repositories.MessageRefIdRepository
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package uk.gov.hmrc.cbcr.controllers

import java.time.LocalDate
import javax.inject.{Inject, Singleton}
import play.api.Logger
import play.api.libs.json.Json
import play.api.mvc.ControllerComponents
Expand All @@ -26,7 +24,9 @@ import uk.gov.hmrc.cbcr.models._
import uk.gov.hmrc.cbcr.repositories.ReportingEntityDataRepo
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import java.time.LocalDate
import java.time.format.DateTimeParseException
import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}
import scala.util.control.NonFatal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package uk.gov.hmrc.cbcr.controllers

import org.mongodb.scala.model.Filters.equal

import javax.inject.{Inject, Singleton}
import play.api.Configuration
import play.api.libs.json.{JsError, JsValue, Json}
import play.api.mvc.{Action, AnyContent, ControllerComponents}
Expand All @@ -29,6 +27,7 @@ import uk.gov.hmrc.cbcr.repositories.SubscriptionDataRepository
import uk.gov.hmrc.mongo.play.json.Codecs
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package uk.gov.hmrc.cbcr.controllers.test

import java.time.LocalDate

import javax.inject.{Inject, Singleton}
import play.api.libs.json.{JsValue, Json}
import play.api.mvc._
import uk.gov.hmrc.cbcr.models._
import uk.gov.hmrc.cbcr.repositories.{DocRefIdRepository, MessageRefIdRepository, ReportingEntityDataRepo, SubscriptionDataRepository}
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController

import java.time.LocalDate
import javax.inject.{Inject, Singleton}
import scala.concurrent.ExecutionContext

@Singleton
Expand Down
4 changes: 2 additions & 2 deletions app/uk/gov/hmrc/cbcr/models/BusinessPartnerRecord.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

package uk.gov.hmrc.cbcr.models
import play.api.libs.json._
import play.api.libs.json.Reads._
import play.api.libs.functional.syntax._ // Combinator syntax
import play.api.libs.json.Reads._
import play.api.libs.json._

case class EtmpAddress(
addressLine1: String,
Expand Down
5 changes: 3 additions & 2 deletions app/uk/gov/hmrc/cbcr/models/DocRefID.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package uk.gov.hmrc.cbcr.models

import java.time.format.DateTimeFormatter
import org.apache.commons.codec.net.URLCodec
import play.api.libs.json._
import play.api.mvc.PathBindable
import org.apache.commons.codec.net.URLCodec

import java.time.format.DateTimeFormatter

case class DocRefId(id: String)
object DocRefId {
Expand Down
7 changes: 4 additions & 3 deletions app/uk/gov/hmrc/cbcr/models/ReportingEntityData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package uk.gov.hmrc.cbcr.models

import java.time.LocalDate
import cats.data.NonEmptyList
import play.api.libs.json._
import play.api.libs.json.Reads._
import play.api.libs.functional.syntax._
import play.api.libs.json.Reads._
import play.api.libs.json._

import java.time.LocalDate

case class EntityReportingPeriod(startDate: LocalDate, endDate: LocalDate)
object EntityReportingPeriod {
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/cbcr/models/SubscriptionData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package uk.gov.hmrc.cbcr.models

import play.api.libs.functional.syntax._ // Combinator syntax
import play.api.libs.json._
import uk.gov.hmrc.emailaddress.EmailAddress
import uk.gov.hmrc.emailaddress.PlayJsonFormats._
import play.api.libs.functional.syntax._ // Combinator syntax

case class SubscriberContact(
name: Option[String],
Expand Down
8 changes: 4 additions & 4 deletions app/uk/gov/hmrc/cbcr/models/SubscriptionRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package uk.gov.hmrc.cbcr.models

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import play.api.libs.json.Reads._ // Custom validation helpers
import play.api.libs.functional.syntax._ // Combinator syntax

import play.api.libs.json.Reads._ // Custom validation helpers
import play.api.libs.json._
import uk.gov.hmrc.emailaddress.EmailAddress
import uk.gov.hmrc.emailaddress.PlayJsonFormats._

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

class PhoneNumber private (val number: String)

//Must match telephone type from API docs
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/cbcr/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package uk.gov.hmrc

import _root_.play.api.Logger
import _root_.play.api.libs.json.Json._
import _root_.play.api.libs.json._
import _root_.play.api.Logger
import cats.data.{EitherT, OptionT}
import uk.gov.hmrc.cbcr.models.InvalidState
import uk.gov.hmrc.http.HeaderCarrier
Expand Down
6 changes: 5 additions & 1 deletion app/uk/gov/hmrc/cbcr/repositories/DocRefIdRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package uk.gov.hmrc.cbcr.repositories

import org.mongodb.scala.model.Filters._
import org.mongodb.scala.model.Indexes.ascending
import org.mongodb.scala.model.Updates.set
import org.mongodb.scala.model.{IndexModel, IndexOptions}
import org.mongodb.scala.result.DeleteResult
import uk.gov.hmrc.cbcr.models.DocRefIdResponses._
import uk.gov.hmrc.cbcr.models._
Expand All @@ -35,7 +37,9 @@ class DocRefIdRepository @Inject() (mongo: MongoComponent, records: ReactiveDocR
mongoComponent = mongo,
collectionName = "DocRefId",
domainFormat = DocRefId.format,
indexes = Seq()
indexes = Seq(
IndexModel(ascending("id"), IndexOptions().name("id"))
)
) {

override lazy val requiresTtlIndex: Boolean = false
Expand Down
4 changes: 2 additions & 2 deletions app/uk/gov/hmrc/cbcr/services/DocRefIdClearService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

package uk.gov.hmrc.cbcr.services

import javax.inject.{Inject, Singleton}
import cats.instances.all._
import cats.syntax.all._
import play.api.libs.json.Json
import play.api.Logger
import play.api.libs.json.Json
import uk.gov.hmrc.cbcr.config.ApplicationConfig
import uk.gov.hmrc.cbcr.models.DocRefId
import uk.gov.hmrc.cbcr.repositories.{DocRefIdRepository, ReportingEntityDataRepo}
import uk.gov.hmrc.play.audit.http.connector.{AuditConnector, AuditResult}
import uk.gov.hmrc.play.audit.model.ExtendedDataEvent

import javax.inject.{Inject, Singleton}
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, ExecutionContext, Future}
import scala.util.chaining.scalaUtilChainingOps
Expand Down
9 changes: 5 additions & 4 deletions app/uk/gov/hmrc/cbcr/services/EmailService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import javax.inject.{Inject, Singleton}
import play.api.Logger
import play.api.libs.json.{JsString, Json}
import play.api.mvc.Result
import play.api.mvc.Results._
import uk.gov.hmrc.cbcr.connectors.EmailConnectorImpl
import uk.gov.hmrc.cbcr.models.Email
import play.api.mvc.Results._

import scala.concurrent.{ExecutionContext, Future}
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.play.audit.model.ExtendedDataEvent
import uk.gov.hmrc.play.audit.http.connector.{AuditConnector, AuditResult}
import uk.gov.hmrc.play.audit.model.ExtendedDataEvent

import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
class EmailService @Inject() (emailConnector: EmailConnectorImpl, auditConnector: AuditConnector)(implicit
Expand Down

0 comments on commit 736436f

Please sign in to comment.