Skip to content

Commit

Permalink
Revert "Recent job names from status resource".
Browse files Browse the repository at this point in the history
This was meant to be used to solve the issue of stable job colors across graphs. Will have to wait for #31 possibly to be properly supported

This reverts commit ae105b0.
  • Loading branch information
cburgmer committed Nov 24, 2016
1 parent 0bd4134 commit 6bfe0b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
30 changes: 6 additions & 24 deletions src/buildviz/controllers/status.clj
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
(ns buildviz.controllers.status
(:require [buildviz.data.results :as results]
[buildviz.util.http :as http]
[clj-time
[coerce :as tc]
[core :as t]]))

;; We manually calculate this period to be in sync with the JS implementation
(def ^:private two-months (* 2 30 24 60 60 1000))

(defn- recent-jobs [all-builds]
(let [two-months-ago (- (tc/to-long (t/now)) two-months)]
(filter #(< two-months-ago (:start %))
all-builds)))

(defn- build-starts [all-builds]
(->> all-builds
(map :start)
(remove nil?)))
[buildviz.util.http :as http]))

(defn get-status [build-results pipeline-name]
(let [all-builds (results/all-builds build-results)
total-build-count (count all-builds)
build-starts (seq (build-starts all-builds))
recent-job-names (->> (recent-jobs all-builds)
(map :job)
distinct
seq)]
build-starts (->> all-builds
(map :start)
(remove nil?)
seq)]
(http/respond-with-json (cond-> {:totalBuildCount total-build-count}
pipeline-name (assoc :pipelineName pipeline-name)
build-starts (assoc :latestBuildStart (apply max build-starts)
:earliestBuildStart (apply min build-starts))
recent-job-names (assoc :recentJobNames recent-job-names)))))
:earliestBuildStart (apply min build-starts))))))
13 changes: 1 addition & 12 deletions test/buildviz/controllers/status_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,4 @@
pipeline-name)
body (json-body (json-get-request (the-app) "/status"))]
(is (= pipeline-name
(get body "pipelineName")))))

(testing "should return names of recent jobs"
(let [today (tc/to-long (t/now))
app (the-app {"aBuild" {"1" {:start today}
"2" {:start (- today (* 60 a-day))}}
"anotherBuild" {"3" {:start (- today (* 60 a-day))}}}
{})]
(is (= ["aBuild"]
(-> (json-get-request app "/status")
json-body
(get "recentJobNames")))))))
(get body "pipelineName"))))))

0 comments on commit 6bfe0b8

Please sign in to comment.