            :job-instances (list (assoc aggregated-build
                                        :junit-xml aggregated-junit-xml)))))
 
-(defn- aggregate-jobs-for-selected-stages [stage-instance aggregate-jobs-for-pipelines]
+(defn- aggregate-jobs-for-stage-instance [stage-instance sync-jobs-for-pipelines]
   (let [{pipeline-name :pipelineName} stage-instance]
-    (if (contains? aggregate-jobs-for-pipelines pipeline-name)
-      (aggregate-jobs-for-stage stage-instance)
-      stage-instance)))
+    (if (contains? sync-jobs-for-pipelines pipeline-name)
+      stage-instance
+      (aggregate-jobs-for-stage stage-instance))))
 
 
 (defn- build-for-job [stage-instance job-name]


;; run

(defn- emit-start [sync-start-time aggregate-jobs-for-pipelines pipeline-stages]
  (println "Looking at pipeline groups" (distinct (map :group pipeline-stages)))
  (println "Syncing all stages starting from" (tf/unparse (:date-time tf/formatters) sync-start-time))
  (when (some? aggregate-jobs-for-pipelines)
    (println "Aggregating jobs for stages of" aggregate-jobs-for-pipelines))

  (println "Finding all pipeline runs for syncing...")


   ["-f" "--from DATE" "DATE from which on builds are loaded (by default tries to pick up where the last run finished)"
    :id :sync-start-time
    :parse-fn #(tf/parse date-formatter %)]
   ["-j" "--sync-jobs PIPELINE" "PIPELINE for which Go jobs will be synced individually (not aggregated inside stage)"
    :id :sync-jobs
    :default '()
    :assoc-fn (fn [previous key val] (assoc previous key (conj (get previous key) val)))]
   ["-h" "--help"]])
