   (when timestamp
     (str timestamp)))
 
-(defn- is-finished [status]
+(defn- finished? [status]
   (contains? #{:success :failure :killed} status))
 
 (defn- step-id-str [step-id]

  (println x)
  x)

(defn build-step-events-to-ws [pipeline ws-ch build-id step-id]
  (let [ctx        (:context pipeline)
        subscription (event-bus/subscribe ctx :step-result-updated)
        payloads     (event-bus/only-payload subscription)
        filtered     (only-matching-step payloads build-id step-id)]
    (on-close ws-ch (fn [_] (event-bus/unsubscribe ctx :step-result-updated subscription)))
    (println "Output-Websocket: Initializing for " build-id step-id)
    (send! ws-ch (lambdacd.util/to-json {:stepResult (-> (state-from-pipeline pipeline)
                                                   (get build-id)
                                                   (get (to-step-id step-id)))
                                         :buildId build-id
                                         :stepId step-id}))
    (async/go-loop []
      (if-let [event (async/<! filtered)]
        (do
          (send! ws-ch (json/write-str event))
          (recur))))))

(defn- subscribe-to-step-result-update [pipeline req build-id step-id]
  (with-channel req ws-ch

(ns lambdaui.api
  (:require [org.httpkit.server :refer [with-channel on-close on-receive send! close]]
            [compojure.core :refer [routes GET POST defroutes context]]
            [ring.util.response :refer [response header]]
            [lambdacd.presentation.unified]
