Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BDOG-3119: removes mongo instant formatting #909

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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