        (doall
         (pmap transact-published tweets)))))
 
-  (->> (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
-                                                $lt (t/date-time 2014 10 1)}
-                                   :in_reply_to_status_id nil
-                                   :retweeted_status.id nil
-                                   :entities.urls {$ne []}
-                                   :user.screen_name {$nin news-accounts}})
-       count
-       aprint
-       time)
+  ;; export retweets
+  (letfn [(transact-published [{:keys [user _id created_at entities id_str retweeted_status] :as tweet}]
+            (let [uid (:_id (mc/find-one-as-map @db "users" {:id (:id user)}))
+                  hids (if-not (empty? (:hashtags entities))
+                         (->> (:hashtags entities)
+                              (pmap #(:_id (mc/find-one-as-map @db "hashtags" (:text (:text %)))))
+                              (into #{})
+                              vec)
+                         nil)
+                  user-mentions (if-not (empty (:user_mentions entities))
+                                  (->> (:user_mentions entities)
+                                       (pmap #(:_id (mc/find-one-as-map @db "users" {:id (:id %)}))))
+                                  #{})
+                  pub-id (store-published uid _id nil :retweet hids created_at)
+                  source-tid (:_id (mc/find-one-as-map @db "published" {:tweet (:_id (mc/find-one-as-map @db "tweets" {:id_str (:id_str retweeted_status)}))}))]
+              (do
+                (doall (pmap #(when-not (nil? %) (store-mention % pub-id)) user-mentions))
+                (store-reaction pub-id source-tid))))]
+    (let [retweets (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
+                                                            $lt (t/date-time 2014 8 1)}
+                                               :retweeted_status {$ne nil}
+                                               :user.screen_name {$nin news-accounts}})]
+      (time (doall (pmap transact-published retweets)))))
 
 
 )



(defn store-published [uid tid url-id type hids ts]
  (mc/insert
   @db
   "published"
   {:user uid

    :tweet tid
    :ts ts}))


(defn store-mention
  "Yeah"
  [uid tid]
  (mc/insert
   @db
   "mentions"
   {:user uid
    :tweet tid}))


(defn store-hashtag [text]
  (mc/insert
   @db
   "hashtags"
   {:text text}))


(defn store-reaction
  "a reaction"
  [pub-id source-id]
  (mc/insert @db "reactions" {:publication pub-id :source source-id}))



(comment

