Last active
July 15, 2020 10:32
-
-
Save tkych/6593401 to your computer and use it in GitHub Desktop.
This script shows github commit statistics as sparkline.
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
;;;; Last modified: 2013-09-18 07:21:52 tkych | |
;; This script is in the public domain. | |
;; Latest version is available at https://gist.github.com/tkych/6593401 | |
;;==================================================================== | |
;; GitHub Commit Statistics | |
;;==================================================================== | |
;; | |
;; Usage: | |
;; ------ | |
;; | |
;; * (show-github-commit-stats "robert-strandh" "SICL" :max 30) | |
;; => "▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▅▃▄▃▂▅▇▄▄█▂▁▁▁▁▁▅▁▆██▅█▅███▅▃▁▆▃███▇" | |
;; * (show-github-commit-stats "robert-strandh" "SICL" :max 30 | |
;; :owner-only? t) | |
;; => "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂█▅███▅▃▁▆▃███▇" | |
;; | |
;;-------------------------------------------------------------------- | |
(eval-when (:compile-toplevel :load-toplevel :execute) | |
(ql:quickload '(:cl-spark :drakma :flexi-streams :yason))) | |
(defun show-github-commit-stats (owner repo &key (min 0) (max 10) (detail? nil) | |
(owner-only? nil)) | |
(let* ((response (handler-case | |
(drakma:http-request | |
(format nil "https://api.github.com/repos/~A/~A/stats/participation" | |
owner repo)) | |
(error (c) | |
(RETURN-FROM show-github-commit-stats | |
(format *error-output* "Fetch Fail [~S]" (type-of c)))))) | |
(json (yason:parse | |
(flexi-streams:octets-to-string response) | |
:object-as :alist)) | |
(stats-list (cdr (assoc (if owner-only? "owner" "all") | |
json :test #'string=)))) | |
(funcall (if detail? #'cl-spark:vspark #'cl-spark:spark) | |
stats-list :min min :max max))) | |
;;==================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment