 
 (def date-formatter (tf/formatter tz "YYYY-MM-dd" "YYYY/MM/dd" "YYYYMMdd" "dd.MM.YYYY"))
 
-(declare go-url)
-(declare buildviz-url)
-
 (defn usage [options-summary]
   (string/join "\n"
                [""

      (goaggregate/aggregate-jobs-for-stage stage-instance))))


(defn- build-for-job [stage-instance job-name]
  (let [job-instance (assoc stage-instance :job-name job-name)]
    (-> (goapi/build-for go-url job-instance)
        (assoc :name job-name)
        (assoc :junit-xml (goapi/get-junit-xml go-url job-instance)))))

(defn- add-job-instances-for-stage-instance [stage-instance]
  (let [job-names (:job-names stage-instance)]
    (assoc stage-instance
           :job-instances (map #(build-for-job stage-instance %) job-names))))


(defn parse-stage-instance [{pipeline-run :pipeline_counter

   :scheduled-time (tc/from-long (apply min (map :scheduled_date jobs)))
   :job-names (map :name jobs)})

(defn stage-instances-from [go-url sync-start-time {stage-name :stage pipeline-name :pipeline}]
  (let [safe-build-start-date (t/minus sync-start-time (t/millis 1))]
    (->> (goapi/get-stage-history go-url pipeline-name stage-name)
         (map parse-stage-instance)
