Skip to content

Commit

Permalink
Merge pull request #909 from hmrc/BDOG-3119
Browse files Browse the repository at this point in the history
BDOG-3119: removes mongo instant formatting
  • Loading branch information
Tyrpix committed Jun 28, 2024
2 parents 8016737 + 0149537 commit b24fe88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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")

Expand Down Expand Up @@ -124,15 +121,14 @@ object Indicator:
~ (__ \ "weightedMetrics").read[Seq[WeightedMetric]]
)(Indicator.apply)


case class DataPoint(
timestamp : Instant,
overallScore: Int
)

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))

Expand All @@ -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))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -127,16 +126,6 @@ class HealthIndicatorsConnectorSpec
"description": "No Readme defined"
}
]
},
{
"metricType": "build-stability",
"score": 0,
"breakdown": [
{
"points": 0,
"description": "Build Not Found"
}
]
}
]
}"""
Expand Down

0 comments on commit b24fe88

Please sign in to comment.