                        ;; (max 0), is this a bug upstream? can be negative? data race?
                        {:queued (max 0 (- (:enqueued v) (:completed v)))
                         :active (max 0 (:in-progress v))
-                        :puts/sec      (double (/ (count (drop-while #(> (- now %) (* 1e9 (conf :stats :window-seconds))) (get-in s [:stats k :puts])))      (conf :stats :window-seconds)))
-                        :completes/sec (double (/ (count (drop-while #(> (- now %) (* 1e9 (conf :stats :window-seconds))) (get-in s [:stats k :completes]))) (conf :stats :window-seconds)))})))
+                        :puts/sec      (-rate-per-sec now s [:stats k :puts])
+                        :completes/sec (-rate-per-sec now s [:stats k :completes])})))
             {})
            lib/json-dumps)})
 

  (let [[stats size] (if (nil? stats)
                       [[] 0]
                       [stats (count stats)])]
    (subvec (conj stats (System/nanoTime))
            (max 0 (inc (- size (conf :stats :count)))))))

(defhandler post-complete
  [req]

    (timbre/debug "put!" queue-name item)
    {:status 200}))

(defn -rate-per-sec
  [now s ks]
  (let [num-events (->> ks
                     (get-in s)
                     -get-current-stats
                     (drop-while #(> (- now %) (* 1e9 (conf :stats :window-seconds))))
                     count)]
    (double (/ num-events (conf :stats :window-seconds)))))

(defhandler get-stats
  [req]
  {:status 200
