|
18 | 18 | "handles original, retweeted tweet"
|
19 | 19 | (if (contains? tweet :retweeted_status)
|
20 | 20 | (let [state @app
|
21 |
| - rt (:retweeted_status tweet) |
22 |
| - rt-id (keyword (:id_str rt)) |
23 |
| - prev (rt-id (:retweets state)) |
24 |
| - prev-rt-count (rt-id (:rt-since-startup state))] |
| 21 | + rt (:retweeted_status tweet) rt-id (keyword (:id_str rt)) |
| 22 | + prev (rt-id (:retweets state)) prev-rt-count (rt-id (:rt-since-startup state))] |
25 | 23 | (when (not (nil? prev))
|
26 | 24 | (mod-sort-set app :by-retweets disj :retweet_count (:retweet_count prev) rt)
|
27 | 25 | (mod-sort-set app :by-favorites disj :favorite_count (:favorite_count prev) rt))
|
|
32 | 30 | (mod-sort-set app :by-rt-since-startup conj :count (inc prev-rt-count) rt)
|
33 | 31 | (if (> (:retweet_count rt) (:retweet_count prev))
|
34 | 32 | (swap! app assoc-in [:retweets (keyword (:id_str rt))] (util/format-tweet rt))
|
35 |
| - (swap! app assoc-in [:retweets :latest] rt) |
36 |
| - ) |
| 33 | + (swap! app assoc-in [:retweets :latest] rt)) |
37 | 34 | (mod-sort-set app :by-retweets conj :retweet_count (:retweet_count rt) rt)
|
38 | 35 | (mod-sort-set app :by-favorites conj :favorite_count (:favorite_count rt) rt))))
|
39 | 36 |
|
|
48 | 45 | {:followers_count (:followers_count (:user tweet))
|
49 | 46 | :id (:id_str tweet)}))
|
50 | 47 | (swap! app assoc :by-id (conj (:by-id state) (:id_str tweet)))
|
51 |
| - (. word-cloud (redraw (clj->js (take 250 (:words-sorted-by-count state))))) )) |
| 48 | + (. word-cloud (redraw (clj->js (take 250 (:words-sorted-by-count state))))))) |
52 | 49 |
|
53 | 50 | (defn receive-sse [tweets-chan e]
|
54 | 51 | "callback, called for each item (tweet) received by SSE stream"
|
55 | 52 | (let [tweet (js->clj (JSON/parse (.-data e)) :keywordize-keys true)]
|
56 | 53 | (put! tweets-chan tweet)))
|
57 | 54 |
|
58 |
| -(defn start-search [app search tweets-chan ajax-results-chan] |
| 55 | +(defn start-search [app search tweets-chan] |
59 | 56 | "initiate new search by starting SSE stream"
|
60 | 57 | (let [s (if (= search "") "*" search)]
|
61 | 58 | (if (not (nil? (:stream @app))) (.close (:stream @app)))
|
|
64 | 61 | (aset js/window "location" "hash" (js/encodeURIComponent s))
|
65 | 62 | (swap! app assoc :stream (js/EventSource. (str "/tweetFeed?q=" s)))
|
66 | 63 | (.addEventListener (:stream @app) "message" #(receive-sse tweets-chan %) false)
|
67 |
| - (ajax/prev-search "*" 500 0 ajax-results-chan) |
68 |
| - (ajax/prev-search "*" 500 500 ajax-results-chan) |
69 |
| - (ajax/prev-search "*" 500 1000 ajax-results-chan) |
70 |
| - (ajax/prev-search "*" 500 1500 ajax-results-chan) |
71 |
| - (ajax/prev-search "*" 500 2000 ajax-results-chan) |
72 |
| - )) |
| 64 | + (doall (for [x (range 5)] (ajax/prev-search "*" 500 (* 500 x)))))) |
0 commit comments