 
 (def coll "tweets")
 
+(defn read-data [path]
+  (split (slurp path) #"\n"))
+
+#_(time (doall (map #(insert (json/read-str % :key-fn keyword)) (read-data "/home/konny/data/tweets.json"))))
+
 (defn insert [tweet]
   (mc/insert db coll tweet))
+
 
 (defn inverted-index [news-accounts]
   (->> (mc/find db coll {"entities.user_mentions.screen_name" {$in news-accounts}})

            [monger.collection :as mc]
            [monger.operators :refer :all]
            [monger.conversion :refer [from-db-object]]
            [clj-time.format :as f]
            [clj-time.core :as t]))


       (map #(from-db-object % true))))


(defn get-replies [id]
  (->> (mc/find db coll {"in_reply_to_status_id" id})
       seq
       (map #(from-db-object % true))))


(defn assemble [news-accounts]
  (->> (map
        (fn [account]
          (vec [account
                (->> (get-news account)
                     (map #(vec [(:id %)
                                 (into {} [[:tweet %]
                                           [:retweets {}]
                                           [:replies {}]
                                           [:shared {}]])]))
                     vec
                     (into {}))]))
        news-accounts)
       vec
       (into {})))

(comment

  (def news-accounts ["FAZ_NET" "dpa" "tagesschau" "SPIEGELONLINE" "SZ"])

)
