 
 (require '[cheshire.core :as j]
          '[clj-http.client :as client]
+         '[clj-time.core :as t]
          '[clj-time.format :as tf]
          '[clj-time.coerce :as tc]
          '[clojure.tools.cli :refer [parse-opts]])

(def go-url (second (:arguments args)))
(def buildviz-url (:buildviz-url (:options args)))

(def selected-pipeline-group-names (set (drop 2 (:arguments args))))

(println "Storing build information to" buildviz-url)
(println "Reading groups" selected-pipeline-group-names "from url" go-url)

;; util



(defn job-instances-for-stage [{stage :stage pipeline :pipeline}]
  (map #(assoc % :stageName stage :pipelineName pipeline)
       (take-while #(.isAfter (:scheduledDateTime %) load-builds-from)
                   (mapcat job-instances-for-stage-instance
                           (fetch-all-stage-history pipeline stage)))))


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