Skip to content

Commit f39a569

Browse files
committed
improved readability, arity-1 function
1 parent 810d5e6 commit f39a569

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Clojure-Websockets/src/clj/birdwatch/twitterclient/processing.clj

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"Stateful transducer, counts processed items and updating last-received atom. Logs progress every 1000 items."
1111
(fn [step]
1212
(let [cnt (atom 0)]
13-
(fn [r x]
14-
(swap! cnt inc)
15-
(when (zero? (mod @cnt 1000)) (log/info "processed" @cnt "since startup"))
16-
(reset! last-received (t/now))
17-
(step r x)))))
13+
(fn
14+
([r] (step r))
15+
([r x]
16+
(swap! cnt inc)
17+
(when (zero? (mod @cnt 1000)) (log/info "processed" @cnt "since startup"))
18+
(reset! last-received (t/now))
19+
(step r x))))))
1820

1921
(defn- insert-newline [s]
2022
"inserts missing line breaks after end of tweet"
@@ -26,10 +28,10 @@
2628
(fn
2729
([r] (step r))
2830
([r x]
29-
(let [json-lines (-> (str @buff x) (insert-newline) (str/split-lines))
30-
to-process (butlast json-lines)]
31-
(reset! buff (last json-lines))
32-
(if to-process (reduce step r to-process) r)))))))
31+
(let [json-lines (-> (str @buff x) (insert-newline) (str/split-lines))
32+
to-process (butlast json-lines)]
33+
(reset! buff (last json-lines))
34+
(if to-process (reduce step r to-process) r)))))))
3335

3436
(defn- tweet? [data]
3537
"Checks if data is a tweet. If so, pass on, otherwise log error."
@@ -52,7 +54,3 @@
5254

5355
(defn ex-handler [ex]
5456
(log/error "Exception while processing chunk" ex))
55-
56-
57-
58-

0 commit comments

Comments
 (0)