    {:tweet record
     :article article
     :source source
+    :ts ts}))
+
+
+(defn store-origin [{:keys [article record ts source ancestors]}]
+  (mc/insert-and-return
+   (:db @mongo-state)
+   "origins"
+   {:tweet record
+    :article article
+    :source source
+    :ancestors ancestors
     :ts ts}))
 
 

                                    :content-type content-type})))))))


(defn store-url [{:keys [article record ts source]}]
  (mc/insert-and-return
   (:db @mongo-state)

                                  (assoc expanded-url :url (:expanded_url %)))) record-urls))
        articles (if (nil? expanded-urls)
                   nil
                   (map #(assoc % :article (-> (mc/find-one-as-map (:db @mongo-state) "articles" {:url (:url %)}) :_id)) expanded-urls))
        ancestors (trace-parent record [])]
    (if (nil? articles)
      (store-origin (assoc % :record oid :ts ts :source source :ancestors ancestors))
      (doall
       (map
        #(if (:article %)
           (do (store-origin (assoc % :record oid :ts ts :source source :ancestors ancestors))
               (update-in (mc/find-map-by-id (:db @mongo-state) "articles" (:article %)) [:ts] (fn [x] (f/unparse (:custom-formatter @mongo-state) x))))
           (let [article (store-article (assoc % :ts ts))]
             (do (store-origin (assoc % :article (:_id article) :record oid :ts ts :source source :ancestors ancestors))
                 (do (store-url (assoc % :record oid :ts ts :source source))
                     (update-in article [:ts] (fn [x] (f/unparse (:custom-formatter @mongo-state) x)))))))
        articles)))))
