From 0149537208b930222da7acdca3a18cd506b9f491 Mon Sep 17 00:00:00 2001 From: Sam Sloman Date: Thu, 27 Jun 2024 13:08:46 +0100 Subject: [PATCH] BDOG-3119: removes mongo instant formatting --- .../HealthIndicatorsConnector.scala | 8 ++------ .../HealthIndicatorsConnectorSpec.scala | 15 ++------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnector.scala b/app/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnector.scala index 12308b56e..73620e21c 100644 --- a/app/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnector.scala +++ b/app/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnector.scala @@ -21,7 +21,6 @@ import play.api.libs.json._ import uk.gov.hmrc.cataloguefrontend.connector.RepoType import uk.gov.hmrc.http.{HeaderCarrier, HttpReads, StringContextOps} import uk.gov.hmrc.http.client.HttpClientV2 -import uk.gov.hmrc.mongo.play.json.formats.MongoJavatimeFormats import uk.gov.hmrc.play.bootstrap.config.ServicesConfig import java.time.Instant @@ -66,7 +65,6 @@ end HealthIndicatorsConnector enum MetricType: case GitHub extends MetricType case LeakDetection extends MetricType - case BuildStability extends MetricType case AlertConfig extends MetricType object MetricType: @@ -75,7 +73,6 @@ object MetricType: json.validate[String].flatMap: case "github" => JsSuccess(GitHub) case "leak-detection" => JsSuccess(LeakDetection) - case "build-stability" => JsSuccess(BuildStability) case "alert-config" => JsSuccess(AlertConfig) case s => JsError(s"Invalid MetricType: $s") @@ -124,7 +121,6 @@ object Indicator: ~ (__ \ "weightedMetrics").read[Seq[WeightedMetric]] )(Indicator.apply) - case class DataPoint( timestamp : Instant, overallScore: Int @@ -132,7 +128,7 @@ case class DataPoint( object DataPoint: val format: Format[DataPoint] = - ( (__ \ "timestamp" ).format[Instant](MongoJavatimeFormats.instantFormat) // TODO mongo format!? + ( (__ \ "timestamp" ).format[Instant] ~ (__ \ "overallScore").format[Int] )(DataPoint.apply, r => Tuple.fromProductTyped(r)) @@ -155,7 +151,7 @@ case class AveragePlatformScore( object AveragePlatformScore { val format: Format[AveragePlatformScore] = - ( (__ \ "timestamp" ).format[Instant](MongoJavatimeFormats.instantFormat) // TODO mongo format!? + ( (__ \ "timestamp" ).format[Instant] ~ (__ \ "averageScore").format[Int] )(AveragePlatformScore.apply, r => Tuple.fromProductTyped(r)) } diff --git a/test/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnectorSpec.scala b/test/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnectorSpec.scala index 12cc54b34..87e91b050 100644 --- a/test/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnectorSpec.scala +++ b/test/uk/gov/hmrc/cataloguefrontend/healthindicators/HealthIndicatorsConnectorSpec.scala @@ -25,7 +25,7 @@ import org.scalatestplus.play.guice.GuiceOneAppPerSuite import play.api.Application import play.api.inject.guice.GuiceApplicationBuilder import uk.gov.hmrc.cataloguefrontend.connector.RepoType -import uk.gov.hmrc.cataloguefrontend.healthindicators.MetricType.{BuildStability, GitHub, LeakDetection} +import uk.gov.hmrc.cataloguefrontend.healthindicators.MetricType.{GitHub, LeakDetection} import uk.gov.hmrc.http.HeaderCarrier import uk.gov.hmrc.http.test.WireMockSupport @@ -64,8 +64,7 @@ class HealthIndicatorsConnectorSpec val weightedMetrics = Seq( WeightedMetric(LeakDetection , 0 , Seq()), - WeightedMetric(GitHub , -50, Seq(Breakdown(-50, "No Readme defined", None))), - WeightedMetric(BuildStability, 0 , Seq(Breakdown(0 , "Build Not Found" , None))) + WeightedMetric(GitHub , -50, Seq(Breakdown(-50, "No Readme defined", None))) ) val expectedResponse = Indicator("team-indicator-dashboard-frontend", RepoType.Service, -450, weightedMetrics) @@ -127,16 +126,6 @@ class HealthIndicatorsConnectorSpec "description": "No Readme defined" } ] - }, - { - "metricType": "build-stability", - "score": 0, - "breakdown": [ - { - "points": 0, - "description": "Build Not Found" - } - ] } ] }"""