             (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]

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

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

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

  (c-route/resources "/"))


(defn prep-rules-for-saving [rules-list]
  (map
   (fn [[k v]] {:name  k  :predicate (pr-str v)})
   rules-list))

(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-rules)))
    (db/save
     (prep-rules-for-saving rule-predicate-forms)
     "categoryrules"))
  (if (nil? (seq (get-data)))
    (import-file test-data)))

