Skip to content

Instantly share code, notes, and snippets.

@kyptin
Created March 2, 2020 15:58
Show Gist options
  • Save kyptin/202370fe619507cf4f3c88f79020eaee to your computer and use it in GitHub Desktop.
Save kyptin/202370fe619507cf4f3c88f79020eaee to your computer and use it in GitHub Desktop.
Fetch commit author frequences from the GitHub API (COMP 590 in-class exercise)
(ns commits
(:require [clj-http.client :as http]
[clj-json.core :as json]
[clojure.pprint :refer [pprint]]))
(def api-url "https://api.github.com/repos/clojure/clojure/commits")
(defn get-committers-from-page [n]
(some->> (http/get api-url {:query-params {"per_page" 100, "page" n}})
:body
json/parse-string
(map #(get-in % ["author" "login"]))
(remove nil?)))
(defn -main []
(->> (get-committers-from-page 1)
frequencies
(sort-by val)
pprint))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment