   (let [environments (-> release :environments)
         previous-environments (-> previous-release :environments)]
     (map (fn [env]
-      (let [prev-env-release (filter (fn [prev-env]
-                                (= (:name env) (:name prev-env)))
-                                previous-environments)
-        release-state (get-release-state env prev-env-release)]
-        {:env-name (:name env) :state release-state}))
-     environments)))
+           (let [prev-env-release (filter (fn [prev-env]
+                                            (= (:name env) (:name prev-env)))
+                                          previous-environments)
+                 release-state (get-release-state env prev-env-release)]
+             {:env-name (:name env) :state release-state}))
+         environments)))
 
 (defn- generate-release-info [release previous-release]
-   {:release-definition-name (-> :releaseDefinition release :name)
-    :release-definition-id (:id release)
-    :release-number (:name release)
-    :release-environments (generate-release-environments release previous-release)})
+  {:release-definition-name (-> :releaseDefinition release :name)
+   :release-definition-id (:id release)
+   :release-number (:name release)
+   :release-environments (generate-release-environments release previous-release)})
 
 (defn generate-build-info [build previous-build commit-message]
   (let [state (get-state build previous-build)]

(defn -main [& [vso-account vso-project vso-personal-access-token port]]
  (let [port (Integer. (or port 3000))]
    (if (and vso-account vso-project vso-personal-access-token port)
      (let [
            vso-api (api/vso-api-fns logger
                                    (api/vso-api-get-fn vso-personal-access-token)
                                     vso-account
                                     vso-project)
            vso-release-api (release-api/vso-release-api-fns
                                    logger
                                    (release-api/vso-release-api-get-fn vso-personal-access-token)
                                    vso-account
                                    vso-project)
            wrapped-handler (-> (handlers vso-api vso-release-api)
                                    wrap-routes
                                    (resource/wrap-resource "public")
                                    (params/wrap-params))]
        (println "==============================================================")
        (println "Starting up... please enjoy your project monitor #repsforrufus")
        (println "==============================================================")
        (ring-jetty/run-jetty wrapped-handler {:port port}))
      (prn "App didn't start due to missing parameters."))))

            [ring.middleware.params :as params]
            [bidi.bidi :as bidi]
            [cheshire.core :as json]
            [clj-time.core :as t]
            [build-mon.vso-api :as api]
            [build-mon.vso-release-api :as release-api]
            [build-mon.html :as html])
  (:gen-class))

(def logger {:log-exception (fn [message exception]
                              (println "=========   ERROR   ==========")
                              (println message)
                              (println exception)
                              (println "=============================="))})

(def states-ordered-worst-first [:failed :in-progress-after-failed :in-progress :succeeded])

