       {:size counter
        :height max-path
        :users users
-       ;;:tokens tokens
+       :tokens tokens
        :pub-times pub-times
        :hashtags (mapv #(-> % :text clojure.string/lower-case) hashtags)
        :delays delays}


  (lio/view g)

  (let [user (-> rand-tree second :users last)
        tweets (mc/find-maps @db "tweets" {:user.screen_name user})]
    (->> tweets
         (mapv spread)
         ffirst
         aprint
         time))



  (def sum-tagesschau (time (compute-summary "tagesschau")))

  (def sum-faz (compute-summary "FAZ_NET"))

  (def sum-sz (compute-summary "SZ"))

  (def sum-spon (compute-summary "SPIEGELONLINE"))

  (def sum-welt (compute-summary "welt"))



  ;; publication time of day
  (let [sz-hours (->> sum-sz
                       :pub-times
                       flatten
                       (map t/hour)
                       frequencies
                       (sort-by key <))]
    (view (line-chart (keys sz-hours) (vals sz-hours))))


  ;; reaction delay
  (let [delays (->>  sum-sz
                     :delays
                     (remove #(= % 0))
                     (remove #(> % 3600))
                     frequencies
                     (sort-by key <))]
    (view (line-chart (keys delays) (vals delays))))


  ;; daily tweet counts
  (let [days (t/in-days (t/interval (t/date-time 2014 8 1) (t/date-time 2014 9 15)))
        dates (take days (p/periodic-seq (t/date-time 2014 8 1) (t/days 1)))
        tweet-counts (map
                      (fn [date]
                        (->> sum-sz
                             :pub-times
                             flatten
                             (filter #(and (t/after? % date) (t/before? % (t/plus date (t/days 1)))))
                             count))
                      dates)]
    (view (line-chart (range 1 (inc days)) tweet-counts)))



  ;; tweet counts
  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
        sz-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SZ" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        spon-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "SPIEGELONLINE" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        faz-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "FAZ_NET" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        bild-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "BILD" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        tagesschau-tweet-count (map #(mc/count @db "tweets" {:user.screen_name "tagesschau" :created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        days-since-start (apply concat (repeat 5 (range days-running)))
        ;; tweet-count-2 (loop [hours-list [] tweet-dist tweet-count] (if (empty? tweet-dist) hours-list (recur (conj hours-list (vec (take 24 tweet-dist))) (drop 24 tweet-dist))))
        ;; avg-tweets-per-hour (map (fn [hour] (/ (reduce + (map (fn [count] (get count hour)) tweet-count-2)) (count tweet-count-2))) (range 24))
        tweet-counts (concat sz-tweet-count spon-tweet-count faz-tweet-count bild-tweet-count tagesschau-tweet-count)
        grouping (apply concat (map #(repeat (count sz-tweet-count) %) ["sz" "spon" "faz" "bild" "tagesschau"]))]
    (view (line-chart days-since-start tweet-counts :legend true :group-by grouping)))


  (let [days-running (t/in-hours (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 12)))
        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/hours 1)))
        tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/hours 1))}}) dates)
        time (range days-running)
        tweet-count-2 (loop [hours-list []
                             tweet-dist tweet-count]
                        (if (empty? tweet-dist)
                          hours-list
                          (recur (conj hours-list (vec (take 24 tweet-dist))) (drop 24 tweet-dist))))
        avg-tweets-per-hour (map (fn [hour] (/ (reduce + (map (fn [count] (get count hour)) tweet-count-2)) (count tweet-count-2))) (range 24))]
    (view (line-chart time tweet-count))
    (view (line-chart (range 24) avg-tweets-per-hour)))


  (let [days-running (t/in-days (t/interval (t/date-time 2014 7 2) (t/date-time 2014 10 13)))
        dates (take days-running (p/periodic-seq (t/date-time 2014 7 2) (t/days 1)))
        tweet-count (map #(mc/count @db "tweets" {:created_at {$gte % $lt (t/plus % (t/days 1))}}) dates)
        days (range  2 (inc (inc days-running)))]
    (view (scatter-plot days tweet-count :title "tweet counts" :y-label "Tweet Count" :x-label "Day")))


  ;; user posts distribution
  (let [users (->> (mc/find-maps
                    @db "tweets"
                    {$and
                     [
                      {:created_at {$gt (t/date-time 2014 7 1)
                                    $lt (t/date-time 2014 10 1)}}
                      {:user.screen_name {$ne news-accounts}}]
                     ["user.screen_name"]})
                   (pmap #(-> % :user :screen_name))
                   frequencies)
        unique-posters #(float (/ (count %) (count users)))
        post-counter (frequencies (vals users))]
    (->> users
         (sort-by second >)
         (take 10)
         aprint))


  ;; news posts fraction
  (let [overall-count (mc/count @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)}})
        news-count (mc/count
                    @db "tweets" {$and [{:created_at {$gt (t/date-time 2014 7 1)}}
                                        {:user.screen_name {$in news-accounts} }]})]
    (aprint (float (/ news-count overall-count))))

  (def origin (time (rand-nth (mc/find-maps @db "origins" {:source {$in news-accounts}}))))

  (println "\n")

  (def tree (time (compute-impact-tree origin)))

  (def dpa-sum (time (compute-summary "dpa")))

  (aprint (keys dpa-sum))

  (def tagesschau-sum (time (compute-summary "tagesschau")))

  (aprint (dissoc dpa-sum :heights :sizes :users :hashtags :pub-times :no-reactions :delays))


  (->> (mc/find-maps @db "tweets" {:created_at {$gt (t/date-time 2014 7 1)
                                                $lt (t/date-time 2014 10 1)}}
                     [:user.id_str])
       (pmap #(-> % :user :id_str))
       (into #{})
       count
       aprint
       time)

  )


         (let [user (-> node :tweet :user)]
             (conj users (:screen_name user)))
         users)
       (if (zip/node loc)
         (conj
          tokens
          (clojure.set/difference
