      :latest-failure (:start last-build)
      :flaky-count (count unrolled-testcases)}))
 
-(defn- flaky-testcase-summaries [unrolled-testcases]
-  (->> unrolled-testcases
-       (group-by transform/testcase->id)
-       (map (transform/testcase-with-data
-             (fn [testcases] (flaky-testcase-summary testcases))))))
-
 (defn flaky-testcases-as-list [builds test-results-func]
   (->> builds
        find-flaky-build-candidates
        (mapcat #(flaky-testcases-for-builds % test-results-func))
-       flaky-testcase-summaries
+       (group-by transform/testcase->id)
+       (map (transform/testcase-with-data
+             (fn [testcases] (flaky-testcase-summary testcases))))
        (map transform/testcase->map)))

             (fn [testcase] {:build build
                             :ok? (junit-xml/is-ok? testcase)})))))

(defn- flaky-testcases-for-builds [builds test-results-func]
  (->> builds
       (mapcat (fn [build]
                 (unrolled-testcases build test-results-func)))
       (group-by transform/testcase->id)

    (assoc (average-runtime testcases)
           :failed-count failed-count)))

(defn- aggregated-info-by-testcase [test-runs]
  (->> (transform/test-runs->testcase-list test-runs)
       (group-by transform/testcase->id)
       (map (transform/testcase-with-data
             (fn [testcase-group] (aggregate-testcase-runs testcase-group))))))


(defn aggregate-testcase-info [test-runs]
  (transform/testcase-list->testsuite-tree (aggregated-info-by-testcase test-runs)))

(defn aggregate-testcase-info-as-list [test-runs]
  (map transform/testcase->map (aggregated-info-by-testcase test-runs)))


(defn- average-runs [unrolled-testcases]
  (->> unrolled-testcases
       (group-by transform/testcase->id)
       (map (transform/testcase-with-data
             (fn [testcase-group] (average-runtime testcase-group))))))

(defn- accumulated-runtime [testcases]
  (let [runtimes (map :runtime testcases)]
