 
 ;; /api/stages/%pipeline/%stage/history
 
-(defn job-instances-for-stage-instance [{pipelineRun :pipeline_counter
-                                         stageRun :counter
+(defn job-instances-for-stage-instance [{pipeline-run :pipeline_counter
+                                         stage-run :counter
                                          jobs :jobs}]
-  (map (fn [{id :id name :name result :result}]
+  (map (fn [{id :id name :name result :result scheduled-date :scheduled_date}]
          {:jobId id
           :jobName name
-          :stageRun stageRun
-          :pipelineRun pipelineRun})
+          :stageRun stage-run
+          :pipelineRun pipeline-run
+          :scheduledDateTime (tc/from-long scheduled-date)})
        jobs))
 
 (defn get-stage-instances [pipeline stage offset]


(defn job-instances-for-stage [{stage :stage pipeline :pipeline}]
  (map #(assoc % :stageName stage :pipelineName pipeline)
       (mapcat job-instances-for-stage-instance
               (fetch-all-stage-history pipeline stage))))


;; /api/pipelines/%pipelines/instance/%run

       (map augment-job-instance-with-junit-xml)))

(put-to-buildviz (map make-build-instance job-instances))

(println (format "Done, wrote %s build entries" (count job-instances)))
