               (:_id (mc/find-one-as-map @db "url" {:url (-> urls first :url expand-url :url)}))
               nil))
           (get-uid [{{id :id} :user}]
-            (:_id (mc/find-one-as-map @db "user" {:id id})))
+            (:_id (mc/find-one-as-map @db "users" {:id id})))
           (dispatch-tweet [{:keys [retweeted_status in_reply_to_status_id]}]
             (if in_reply_to_status_id
               :reply




  ;; export urls
  (time
   (let [origins (mc/find-maps @db "origins" {:source {$ne nil}})]
     (doall
      (map
       (fn [{:keys [article tweet ts source]}]
         (let [uid (:_id (mc/find-one-as-map @db "user" {:screen_name source}))
               url (if article
                     (:url (mc/find-map-by-id @db "articles" article))
                     nil)]
           (if url
             (store-url url uid ts)
             :unknown)))
       origins))))


  ;; export un-parsed urls
  (letfn [(expand-urls [{{:keys [urls]} :entities}]
            (pmap #(let [expanded-url (expand-url (:expanded_url %))]
                    (if expanded-url
                      (:url expanded-url)
                      %)) urls))]
    (let [tweets (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
                                                          $lt (t/date-time 2014 7 29)}
                                             :entities.urls {$ne []}

  (let [date (f/parse custom-formatter created_at)]
      (mc/insert-and-return
       @db
       "users"
       {:id id
        :screen_name screen_name
        :created_at date})))
