   :available-media-types #{"application/json" "text/csv"}
   :known-content-type? #{"application/json" "text/csv"}
   :authorized? (authorized? (:querier store) :measurement)
-  :handle-ok (partial measurements-slice-handle-ok store store-new))
+  :handle-ok (partial measurements-slice-handle-ok store-new))
 
 (defresource index [store store-new queue handlers]
   :allowed-methods #{:post :get}
   :available-media-types #{"application/json"}
   :known-content-type? #{"application/json"}
   :authorized? (authorized? (:querier store) :measurement)
-  :post! (partial index-post! store store-new queue)
-  :handle-ok (partial index-handle-ok store store-new )
+  :post! (partial index-post! store-new queue)
+  :handle-ok (partial index-handle-ok store-new)
   :handle-created index-handle-created)
 
 (defresource measurements-by-reading [store store-new handlers]
   :allowed-methods #{:get}
   :available-media-types #{"application/json"}
   :authorized? (authorized? (:querier store) :measurement)
-  :handle-ok (partial measurements-by-reading-handle-ok store store-new))
+  :handle-ok (partial measurements-by-reading-handle-ok store-new))


(defn retrieve-measurements
  "Iterate over a sequence of months and concatanate measurements retrieved from the database."
  [querier start-date end-date device-id reading-type]
  (let [range  (time-range start-date end-date (t/months 1))
        months (map #(util/get-month-partition-key (tc/to-date %)) range)
        where  [[= :device_id device-id]
                [= :type reading-type]
                [>= :timestamp (tc/to-date start-date)]
                [<= :timestamp (tc/to-date end-date)]]]
    (mapcat (fn [month] (hecuba/items querier :measurement (conj where [= :month month]))) months)))

(defn- parse-measurements [measurements]
  (map (fn [m]

                               (hayt/where [[= :device_id device_id]
                                            [= :type type]])))))

(defn- insert-measurement [session m]
  (dbnew/execute session (hayt/insert :measurements (hayt/values m))))

(defn index-post! [store-new queue ctx]
  (let [request       (:request ctx)
        route-params  (:route-params request)
        device_id     (:device_id route-params)
        topic         (get-in queue ["measurements"])
