-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor using Reduce in count-user-pr function
- Loading branch information
Showing
1 changed file
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,21 +19,25 @@ | |
([org-name token] | ||
"Get Url Events for all Member for org-ame. Requires token and be member" | ||
(map (partial get-value "events_url") (parse->clojure (str base-url "/orgs/" org-name "/members?access_token=" token))))) | ||
|
||
(defn count-user-pr [arr] | ||
(loop [[{type "type" date "created_at" {name "name"} "repo" {login "login"} "actor"} & t] arr prs '()] | ||
(if (empty? type) | ||
(when (> (count prs) 0) | ||
{:user (:actor (first prs)) :score (count prs) :last (:date (last prs))}) | ||
(recur t (if (and (= type "PullRequestEvent") (.startsWith date "2016-10")) | ||
(conj prs {:actor login :repo name :date date}) | ||
prs))))) | ||
|
||
(defn count-user-pr [user-events] | ||
"Count User Pull Request Events" | ||
(if-let [user-score | ||
(reduce (fn [final-prs pr] | ||
(let [{type "type" date "created_at" {name "name"} "repo" {login "login"} "actor"} pr] | ||
(if (and (= type "PullRequestEvent") (.startsWith date "2016-10")) | ||
(conj final-prs {:actor login :repo name :date date}) | ||
final-prs))) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sarcilav
|
||
'() | ||
user-events)] | ||
{:user (:actor (first user-score)) :score (count user-score) :last (:date (last user-score))})) | ||
|
||
;;Get Members Score | ||
(defn -main [& args] | ||
(println "User - Score") | ||
(apply println (map (fn [m] (str "\n" (:user m) " - " (:score m))) | ||
(sort-by :score > (filter (fn [x] (> (count x) 0)) | ||
(sort-by :score > (filter (fn [x] (> (:score x) 0)) | ||
(map count-user-pr | ||
(map parse->clojure (apply members-url-events args)))))))) | ||
|
||
|
I believe it's not necesary this return.
I believe this block maybe:
@sarcilav What do you think about?