Created
January 4, 2015 22:24
-
-
Save sachac/3559caa2770ae63ec437 to your computer and use it in GitHub Desktop.
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
(defun sacha/org-count-tasks-by-status () | |
(interactive) | |
(let ((counts (make-hash-table :test 'equal)) | |
(today (format-time-string "%Y-%m-%d" (current-time))) | |
values) | |
(org-map-entries | |
(lambda () | |
(let* ((status (elt (org-heading-components) 2))) | |
(when status | |
(puthash status (1+ (or (gethash status counts) 0)) counts)))) | |
nil | |
'agenda) | |
(setq values (mapcar (lambda (x) | |
(or (gethash x counts) 0)) | |
'("DONE" "STARTED" "TODO" "WAITING" "DELEGATED" "CANCELLED" "SOMEDAY"))) | |
(insert "| " today " | " | |
(mapconcat 'number-to-string values " | ") | |
" | " | |
(number-to-string (apply '+ values)) | |
" | " | |
(number-to-string | |
(round (/ (* 100.0 (car values)) (apply '+ values)))) | |
"% |\n"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment