             [cfpb.qu.data.aggregation :as agg]
             [clojure.string :as str]
             [clojure.core.cache :as cache :refer [defcache]]
-            [clj-time.core :refer [now]]            
+            [clj-time.core :refer [now]]
+            [clojure.edn :as edn]
             [lonocloud.synthread :as ->]            
             [monger
              [core :as mongo :refer [with-db get-db]]

  "Given a map-reduce job, tells Mongo to perform the job.
   Returns true on success, false on failure."
  [worker job]
  (add-to-cache (:cache worker) (:aggmap job)))

(defn- update-cache
  "Update the query cache to reflect that the map-reduce job is

      (coll/insert-and-return *work-collection* {:_id (:to aggmap)
                                                 :status "unprocessed"
                                                 :created (now)
                                                 :aggmap (pr-str aggmap)})
      (catch MongoException$DuplicateKey e
        (coll/find-map-by-id *work-collection* (:to aggmap))))))

