 (def go-url (second (:arguments args)))
 (def buildviz-url (:buildviz-url (:options args)))
 
+(def load-builds-from (t/minus (t/today-at-midnight) (t/weeks 1)))
+
 (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)
+(println "Will load all builds starting from" (tf/unparse (tf/formatter "yyyy-MM-dd") load-builds-from))
 
 ;; util
 


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


(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
