 (defn hosts-timeseries
   "Get hosts timeseries data for last 24 hours"
   []
-  (let [nodes (->> (docker/nodes)
+  (let [nodes (->> (nodes-memo)
                    (group-by :ID))
         node-name #(or (-> (get nodes %) first :Description :Hostname) %)]
     (->> (-> (influx/read-host-stats)


(defn ready? []
  (not (and (empty? @cache)
            (empty? (active-hosts-memo)))))

(defn store-to-cache
  "Store stats in local cache"

            [swarmpit.influxdb.mapper :as m]
            [swarmpit.config :refer [config]]))

(def nodes-memo (memo/ttl docker/nodes :ttl/threshold 5000))

(defn active-hosts
  []
  "List of running nodes"
  (->> (nodes-memo)
       (filter #(= "ready" (get-in % [:Status :State])))
       (map :ID)
       (set)))

(def cache (atom (cache/basic-cache-factory {})))

