ADD ranked LTG agenda view

This commit is contained in:
Nathan Dwarshuis 2021-12-29 21:32:14 -05:00
parent ab19f2f097
commit 72b702a869
2 changed files with 29 additions and 7 deletions

View File

@ -3055,7 +3055,7 @@ In the order of display
(interactive) (interactive)
(let ((f (list (org-x-get-endpoint-goal-file)))) (let ((f (list (org-x-get-endpoint-goal-file))))
(org-x-update-goal-link-ids) (org-x-update-goal-link-ids)
(nd/org-agenda-call "Ranked Goals" nil 'todo org-x-kw-todo f (nd/org-agenda-call "Ranked EPGs" nil 'todo org-x-kw-todo f
`((org-agenda-sorting-strategy '(priority-down time-up)) `((org-agenda-sorting-strategy '(priority-down time-up))
(org-super-agenda-groups (org-super-agenda-groups
',(nd/org-def-super-agenda-automap ',(nd/org-def-super-agenda-automap
@ -3063,6 +3063,20 @@ In the order of display
(format "Score: %s" score) (format "Score: %s" score)
"No Score"))))))) "No Score")))))))
(defun nd/org-agenda-ranked-lifetime-goals ()
"Show the ranked endpoint goals agenda view."
(interactive)
(let ((f (list (org-x-get-lifetime-goal-file))))
(org-x-update-goal-link-ids)
(nd/org-agenda-call "Ranked LTGs" nil 'todo org-x-kw-todo f
`((org-agenda-sorting-strategy '(priority-down time-up))
(org-super-agenda-groups
',(nd/org-def-super-agenda-automap
;; TODO not DRY
(-when-let (c (org-x-headline-get-category-tag))
(let ((n (alist-get c org-x--quarter-life-categories nil nil #'equal)))
(format "%s. %s" n (or (-some->> c (s-chop-prefix "_")) "NA"))))))))))
;; TODO this is slow and the code isn't pretty to look at, perhaps break into ;; TODO this is slow and the code isn't pretty to look at, perhaps break into
;; several agenda views, or at least refactor the common bits ;; several agenda views, or at least refactor the common bits
(defun nd/org-agenda-goal-groups () (defun nd/org-agenda-goal-groups ()

View File

@ -1288,6 +1288,19 @@ Assumes point is on a valid headline or org mode file."
(org-x-qt-plan-get-categories) (org-x-qt-plan-get-categories)
(setq org-x--quarter-life-categories))) (setq org-x--quarter-life-categories)))
(defun org-x-headline-get-category-tag ()
(--find (s-prefix-p "_" it) (org-get-tags)))
(defun org-x-get-category-score ()
(-when-let (c (org-x-headline-get-category-tag))
(alist-get c org-x--quarter-life-categories nil nil #'equal)))
(defun org-x-lifetime-goal-get-score ()
(let* ((p (aref (org-entry-get nil "PRIORITY") 0))
(priority-score (if (= org-priority-highest p) 1 -1)))
(-when-let (cat-score (org-x-get-category-score))
(* cat-score priority-score))))
(defun org-x-endpoint-goal-get-score () (defun org-x-endpoint-goal-get-score ()
(unless org-x--quarter-life-categories (unless org-x--quarter-life-categories
(error "`org-x--quarter-life-categories' is not set")) (error "`org-x--quarter-life-categories' is not set"))
@ -1296,12 +1309,7 @@ Assumes point is on a valid headline or org mode file."
(link) (link)
(let ((id (org-ml-get-property :path link))) (let ((id (org-ml-get-property :path link)))
(org-x-with-id-target id (org-x-with-id-target id
(let* ((p (aref (org-entry-get nil "PRIORITY") 0)) (org-x-lifetime-goal-get-score)))))
(c (--find (s-prefix-p "_" it) (org-get-tags)))
(priority-score (if (= org-priority-highest p) 1 -1))
(cat-score (alist-get c org-x--quarter-life-categories
nil nil #'equal)))
(* cat-score priority-score))))))
(-some->> (org-x-get-goal-link-property) (-some->> (org-x-get-goal-link-property)
(-map #'get-link-score) (-map #'get-link-score)
(-sum)))) (-sum))))