Skip to content

Commit

Permalink
Added a generation instant to each generated result.
Browse files Browse the repository at this point in the history
  • Loading branch information
ulitol97 committed May 5, 2022
1 parent 8470266 commit 723a838
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions api/src/main/scala/validation/result/ValidationResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import cats.effect.unsafe.implicits.global
import cats.syntax.all._
import es.weso.rdf.jena.RDFAsJenaModel
import es.weso.schema.{Result => ValidationReport}
import io.circe.syntax.EncoderOps
import io.circe.{Encoder, Json}

import java.time.Instant

/**
* Represents the output of validating a piece of streamed data
*
Expand All @@ -20,6 +23,11 @@ import io.circe.{Encoder, Json}
*/
case class ValidationResult(private val inputResult: Either[Throwable, ValidationReport]) {

/**
* Store the moment in which this result was generated
*/
val emission: Instant = Instant.now()

/**
* Final status of the validation
*/
Expand Down Expand Up @@ -59,6 +67,7 @@ case class ValidationResult(private val inputResult: Either[Throwable, Validatio
|Validation result:
|- STATUS: $status
|- MESSAGE: $message
|- DATE: $emission
|- REPORT: ${result.map(getValidationReportJson).map(_.spaces2).getOrElse(noReportMessage)}
|""".stripMargin.strip()
}
Expand All @@ -74,6 +83,7 @@ object ValidationResult {
("valid", Json.fromBoolean(validationResult.status.valid)),
("status", Json.fromString(validationResult.status.textValue)),
("message", Json.fromString(validationResult.message)),
("instant", validationResult.emission.asJson),
// Inject a false here if the report is unavailable (errored results)
("report", validationResult.result.map(getValidationReportJson).getOrElse(Json.fromBoolean(false)))
))
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.1.6"
ThisBuild / version := "0.1.7"

0 comments on commit 723a838

Please sign in to comment.