Skip to content

Commit

Permalink
#53 Set job end date
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Dec 7, 2016
1 parent c165260 commit 52b5ae3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions thehive-cortex/app/connectors/cortex/services/CortexSrv.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package connectors.cortex.services

import java.nio.file.{ Path, Paths }
import java.util.Date

import javax.inject.{ Inject, Singleton }

Expand All @@ -17,7 +18,7 @@ import akka.stream.Materializer
import akka.stream.scaladsl.{ Sink, Source }

import play.api.{ Configuration, Logger }
import play.api.libs.json.JsObject
import play.api.libs.json.{ JsObject, Json }
import play.api.libs.ws.WSClient

import org.elastic4play.{ InternalError, NotFoundError }
Expand Down Expand Up @@ -145,7 +146,11 @@ class CortexSrv @Inject() (
val status = (j \ "status").asOpt[JobStatus.Type].getOrElse(JobStatus.Failure)
val report = (j \ "report").asOpt[JsObject].getOrElse(JsObject(Nil)).toString
log.debug(s"Job $cortexJobId in cortex ${cortex.name} has finished with status $status, updating job ${jobId}")
update(jobId, Fields.empty.set("status", status.toString).set("report", report)).onComplete {
val jobFields = Fields.empty
.set("status", status.toString)
.set("report", report)
.set("endDate", Json.toJson(new Date))
update(jobId, jobFields).onComplete {
case Failure(e) log.error(s"Update job fails", e)
case _
}
Expand Down

0 comments on commit 52b5ae3

Please sign in to comment.