             (ring.middleware [multipart-params :as mp])
             [clojure.java.io :as io]
             [compojure.route :as c-route]
+            [clojure.edn :as edn]
             [ring.server.standalone :as server]
             [ring.middleware.json :as ring-json]
             [spcr.parser :as parser]

  (c-route/resources "/"))


(defn init [env]
  (db/init {:collection-name "rawdata"
            :db-name "spcr-db"
            :uri (if (= env :prod) heroku-mongo-connection-uri nil)})
  (if (nil? (seq (get-data)))
    (import-file test-data)))


  (->> (db/get-all "rawdata")
       (map #(dissoc % :_id))))

(defn get-rules []
  (->> (db/get-all "categoryrules")
       (map (fn [{name :name pred-fn :predicate}]
              [(keyword  name) (eval  (edn/read-string pred-fn))]))
       (into {})))

(defn get-labeled-data [] ;todo add a query mechanism to filter on labels
  (-> (get-data)
      (rule-engine (merge default-rules (get-rules)))))

(defn get-label-stats []
  (->> (get-labeled-data)
