Skip to content

Instantly share code, notes, and snippets.

@clojj
Created January 25, 2015 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clojj/51cbf8301abc36859965 to your computer and use it in GitHub Desktop.
Save clojj/51cbf8301abc36859965 to your computer and use it in GitHub Desktop.
sort starred repos by commit-count in last n days
(ns github-api.core
(:gen-class)
(:require [tentacles.repos :as repos]
[clojure.core.reducers :as r])
(:use [clojure.pprint])
(:import (java.time Period LocalDateTime)))
(defn latest [days token]
(let [starred (repos/starring "clojj"
{:accept "application/vnd.github.v3.star+json" :auth token
;:per-page 15})
:all-pages true})
;git-urls (map #(get-in % [:repo :git_url]) starred)
users-and-names (map (fn [s] [(get-in s [:repo :owner :login]) (get-in s [:repo :name])]) starred)
results (pmap (fn [[user repo]]
[repo (count (repos/commits user repo {:accept "application/vnd.github.v3.star+json" :auth token
:all-pages true :since (-> (LocalDateTime/now) (.minus (Period/ofDays days)) (.toString))}))])
users-and-names)]
;(pprint users-and-names)
(pprint (sort (fn [[_ count1] [_ count2]] (> count1 count2)) (filter (fn [[_ count]] (> count 0)) results)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment