diff --git a/admin/app/com/lucidchart/piezo/admin/controllers/Jobs.scala b/admin/app/com/lucidchart/piezo/admin/controllers/Jobs.scala index c12b34a..4931576 100644 --- a/admin/app/com/lucidchart/piezo/admin/controllers/Jobs.scala +++ b/admin/app/com/lucidchart/piezo/admin/controllers/Jobs.scala @@ -35,7 +35,12 @@ class Jobs(schedulerFactory: WorkerSchedulerFactory) extends Controller { } def getIndex = Action { implicit request => - Ok(com.lucidchart.piezo.admin.views.html.jobs(getJobsByGroup(), None, scheduler.getMetaData)(request)) + val allJobs: List[JobKey] = getJobsByGroup().foldLeft(List[JobKey]())({(finalList, jobsForGroup) => + finalList ::: jobsForGroup._2}) + val jobHistories = allJobs.flatMap({ job => + jobHistoryModel.getJob(job.getName, job.getGroup).headOption + }) + Ok(com.lucidchart.piezo.admin.views.html.jobs(getJobsByGroup(), None, Some(jobHistories), scheduler.getMetaData)(request)) } def getJob(group: String, name: String) = Action { implicit request => diff --git a/admin/app/com/lucidchart/piezo/admin/views/job.scala.html b/admin/app/com/lucidchart/piezo/admin/views/job.scala.html index 49c6146..e33fd1e 100644 --- a/admin/app/com/lucidchart/piezo/admin/views/job.scala.html +++ b/admin/app/com/lucidchart/piezo/admin/views/job.scala.html @@ -185,8 +185,8 @@

Job History

- + @@ -195,8 +195,8 @@

Job History

@jobHistory.get.map { record => - + diff --git a/admin/app/com/lucidchart/piezo/admin/views/jobs.scala.html b/admin/app/com/lucidchart/piezo/admin/views/jobs.scala.html index 762c102..f86b142 100644 --- a/admin/app/com/lucidchart/piezo/admin/views/jobs.scala.html +++ b/admin/app/com/lucidchart/piezo/admin/views/jobs.scala.html @@ -1,6 +1,7 @@ @( jobsByGroup: scala.collection.mutable.Buffer[(String, scala.collection.immutable.List[org.quartz.JobKey])], currentJob: Option[org.quartz.JobDetail], +jobsHistory: Option[List[com.lucidchart.piezo.JobRecord]], schedulerMetadata: org.quartz.SchedulerMetaData, errorMessage: Option[String] = None )( @@ -25,4 +26,35 @@

Select a job

Trigger Name Trigger GroupTrigger Name Success Start Finish
@record.trigger_name @record.trigger_group@record.trigger_name @record.success @record.start @record.finish
+ + + @if(jobsHistory.isDefined) { +

Job History

+ + + + + + + + + + + + + + @jobsHistory.get.map { record => + + + + + + + + + + } + +
Job GroupJob NameTrigger GroupTrigger NameSuccessStartFinish
@record.group@record.name@record.trigger_group@record.trigger_name@record.success@record.start@record.finish
+ } } \ No newline at end of file diff --git a/admin/project/Build.scala b/admin/project/Build.scala index b05e17d..9cda46e 100644 --- a/admin/project/Build.scala +++ b/admin/project/Build.scala @@ -12,7 +12,7 @@ object ApplicationBuild extends Build { jdbc, anorm, "org.quartz-scheduler" % "quartz" % "2.1.7", - "com.lucidchart" %% "piezo-worker" % "1.11" + "com.lucidchart" %% "piezo-worker" % "1.12" ) val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings( diff --git a/worker/build.sbt b/worker/build.sbt index 8908860..504512d 100644 --- a/worker/build.sbt +++ b/worker/build.sbt @@ -2,7 +2,7 @@ name := "piezo-worker" organization := "com.lucidchart" -version := "1.11" +version := "1.12" scalaVersion := "2.11.7" diff --git a/worker/src/main/scala/com/lucidchart/piezo/JobHistoryModel.scala b/worker/src/main/scala/com/lucidchart/piezo/JobHistoryModel.scala index 08ee417..1882f9d 100644 --- a/worker/src/main/scala/com/lucidchart/piezo/JobHistoryModel.scala +++ b/worker/src/main/scala/com/lucidchart/piezo/JobHistoryModel.scala @@ -83,4 +83,32 @@ class JobHistoryModel(props: Properties) { connection.close() } } + + def getJobs(): List[JobRecord] = { + val connection = connectionProvider.getConnection + + try { + val prepared = connection.prepareStatement("""SELECT * FROM job_history ORDER BY start DESC LIMIT 100""") + val rs = prepared.executeQuery() + + var result = List[JobRecord]() + while(rs.next()) { + result :+= new JobRecord( + rs.getString("job_name"), + rs.getString("job_group"), + rs.getString("trigger_name"), + rs.getString("trigger_group"), + rs.getInt("success"), + rs.getTimestamp("start"), + rs.getTimestamp("finish") + ) + } + result + } catch { + case e: Exception => logger.error("error in retrieving jobs", e) + List() + } finally { + connection.close() + } + } }