Skip to content

Instantly share code, notes, and snippets.

@tkych
Last active July 15, 2020 10:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkych/6593401 to your computer and use it in GitHub Desktop.
Save tkych/6593401 to your computer and use it in GitHub Desktop.
This script shows github commit statistics as sparkline.
;;;; 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