File tree 5 files changed +16
-16
lines changed
5 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 2
2
(:gen-class )
3
3
(require [clojure.pprint :as pp]))
4
4
5
- (defn rt-status-reducer [sym]
5
+ (defn- rt-status-reducer [sym]
6
6
(fn [acc val]
7
7
" get map with all items that contain a :retweeted_status. key :id_str value sym called on elem"
8
8
(let [rt (:retweeted_status val)
11
11
(assoc acc (:id_str rt) (sym rt))
12
12
acc))))
13
13
14
- (defn reduce-res [f acc coll]
14
+ (defn- reduce-res [f acc coll]
15
15
" reduce result vector with reducer function f, acc and elem into map"
16
16
(reduce f acc coll))
17
17
Original file line number Diff line number Diff line change 26
26
" get total count of indexed tweets from ElasticSearch"
27
27
(esd/count conn (:es-index conf) " tweet" ))
28
28
29
- (defn strip-tweet [t]
29
+ (defn- strip-tweet [t]
30
30
" take only actually needed fields from tweet"
31
31
(let [u (:user t)]
32
32
{:id_str (:id_str t)
41
41
:profile_image_url (:profile_image_url u)
42
42
:screen_name (:screen_name u)}}))
43
43
44
- (defn strip-source [val]
44
+ (defn- strip-source [val]
45
45
" get tweet stripped down to necessary fields"
46
46
(let [s (:_source val)
47
47
t (strip-tweet s)
Original file line number Diff line number Diff line change 24
24
(:user-access-token conf) (:user-access-token-secret conf)))
25
25
26
26
; ; channels
27
- (def chunk-chan (chan 10000 ))
28
- (def msg-chan (chan ))
27
+ (def ^:private chunk-chan (chan 10000 ))
28
+ (def ^:private msg-chan (chan ))
29
29
30
30
; ; atoms for keeping track of counts, incomplete chunk and last received timestamp
31
- (def last-received (atom (t/epoch )))
32
- (def chunk-buff (atom " " ))
33
- (def counter (atom 0 ))
31
+ (def ^:private last-received (atom (t/epoch )))
32
+ (def ^:private chunk-buff (atom " " ))
33
+ (def ^:private counter (atom 0 ))
34
34
35
- (defn parse [str]
35
+ (defn- parse [str]
36
36
(try
37
37
(let [c @counter
38
38
json (json/read-json str)]
74
74
75
75
; ; streaming connection with Twitter stored in an Atom, can be started and stopped using
76
76
; ; using the start-twitter-conn! and stop-twitter-conn! functions
77
- (def twitter-conn (atom {}))
77
+ (def ^:private twitter-conn (atom {}))
78
78
79
- (defn stop-twitter-conn! []
79
+ (defn- stop-twitter-conn! []
80
80
" stop connection to Twitter Streaming API"
81
81
(let [m (meta @twitter-conn)]
82
82
(when m
File renamed without changes.
Original file line number Diff line number Diff line change 19
19
(let [time-string (. (js/moment. date) (fromNow true ))]
20
20
(if (= time-string " a few seconds" ) " just now" time-string)))
21
21
22
- (defn url-replacer [acc entity]
22
+ (defn- url-replacer [acc entity]
23
23
" replace URL occurences in tweet texts with HTML (including links)"
24
24
(s/replace acc (:url entity)
25
25
(str " <a href='" (:url entity) " ' target='_blank'>" (:display_url entity) " </a>" )))
26
26
27
- (defn hashtags-replacer [acc entity]
27
+ (defn- hashtags-replacer [acc entity]
28
28
" replace hashtags in tweet text with HTML (including links)"
29
29
(let [hashtag (:text entity)]
30
30
(s/replace acc (str " #" hashtag)
31
31
(str " <a href='https://twitter.com/search?q=%23" hashtag " ' target='_blank'>#" hashtag " </a>" ))))
32
32
33
- (defn mentions-replacer [acc entity]
33
+ (defn- mentions-replacer [acc entity]
34
34
" replace user mentions in tweet text with HTML (including links)"
35
35
(let [screen-name (:screen_name entity)]
36
36
(s/replace acc (str " @" screen-name)
37
37
(str " <a href='http://www.twitter.com/" screen-name " ' target='_blank'>@" screen-name " </a>" ))))
38
38
39
- (defn reducer [text coll fun]
39
+ (defn- reducer [text coll fun]
40
40
" generic reducer, allowing to call specified function for each item in collection"
41
41
(reduce fun text coll))
42
42
You can’t perform that action at this time.
0 commit comments