         (recur (split-at 3 remainder) (concat result (list \,) group))))))
 
 
-(defn es-count []
+(defn es-count [api-url]
   (let [c (chan)]
-    (go (let [{{docCount :count} :body} (<! (http/get (es-url :count)))]
+    (go (let [{{docCount :count} :body} (<! (http/get api-url))]
           (>! c docCount)))
     c))
 
-(defn es-agg [url post-body]
+(defn es-agg [api-url post-body]
   (let [c (chan)]
-    (go (let [{agg :body} (<! (http/post url {:json-params
-                                              (-> post-body
-                                                  (assoc :search_type "count")
-;;                                                   (assoc :preference "_primary")
-                                                  )}))]
+    (go (let [{agg :body} (<! (http/post api-url
+                                         {:json-params
+                                          (-> post-body (assoc :search_type "count"))}))]
           (>! c agg)))
     c))
 
 (defcomponent header [app owner opts]
   (will-mount [_]
               (go (while true
-                    (let [docCount (<! (es-count))]
+                    (let [docCount (<! (es-count (-> app :es-api :count)))]
                       (om/update! app [:es-count] docCount))
-                    (<! (timeout poll-interval)))))
+                    (<! (timeout (or (-> app :poll-interval) poll-interval))))))
   (render [_]
           (html [:h3 (:header-text app) " with " (-> app :es-count str commify) " raw data in ES"])))
 

            [cljs.core.async :refer [put! <! >! chan timeout]]
            [searchbot.charts :refer [es-chart]]
            ))


(defn es-url [purpose]
  (case purpose
    :count "/es/stats_avc_30d/avc/_count"
    :agg "/es/stats_avc_1d/avc/_search"
    "/es"))

(def poll-interval 30000)


;;                       (.log js/console (pr-str agg-key))
;;                       (.log js/console (pr-str agg-resp))
                      (om/update! app [:agg agg-key] agg-resp))
                    (<! (timeout (or (-> app :poll-interval) poll-interval))))))
  (render [_] (html [:.hide "Aggregator:" (-> opts :agg-key)])))

;;;;;;;;;;;;;;;;;;
;; meta components

(defcomponent aggregators [app owner opts]
  (render [_] (html [:div (for [agg (:aggregators app)]
                            (om/build aggregator app {:opts agg}))])))

(defn- get-component
  [widget-type]
