ENH update project scanner to handle new ns/bs stuff

This commit is contained in:
Nathan Dwarshuis 2022-03-31 18:19:59 -04:00
parent c41b0bb473
commit 564b231e1c
1 changed files with 34 additions and 29 deletions

View File

@ -1549,7 +1549,7 @@ used for optimization."
(task-default `(:sp-task :task-active (,it-todo ,sched ,dead)))) (task-default `(:sp-task :task-active (,it-todo ,sched ,dead))))
(cond (cond
((equal it-todo org-x-kw-hold) ((equal it-todo org-x-kw-hold)
(new-proj :proj-held)) (new-proj '(:proj-held)))
((and sched child-bss) ((and sched child-bss)
(org-x-dag-bs :error "Projects cannot be scheduled")) (org-x-dag-bs :error "Projects cannot be scheduled"))
((equal it-todo org-x-kw-todo) ((equal it-todo org-x-kw-todo)
@ -1592,16 +1592,17 @@ used for optimization."
`(:sp-iter :iter-complete ,_)) `(:sp-iter :iter-complete ,_))
(org-x-dag-bs :error "Active projects must have at least one active child")) (org-x-dag-bs :error "Active projects must have at least one active child"))
(`(:sp-proj . ,s) (new-proj s)) (`(:sp-proj . ,s) (new-proj s))
(`(:sp-iter :iter-active ,_) (new-proj :proj-active)) (`(:sp-iter :iter-active ,_) (new-proj '(:proj-active)))
(`(:sp-iter :iter-empty) (new-proj :proj-stuck)) (`(:sp-iter :iter-empty) (new-proj '(:proj-stuck)))
(`(:sp-task :task-active (,c-todo ,c-sched ,_)) (`(:sp-task :task-active (,c-todo ,c-sched ,_))
(cond (cond
((equal c-todo org-x-kw-todo) (->> (if c-sched :proj-active ((equal c-todo org-x-kw-todo) (->> (if c-sched :proj-active
:proj-stuck) :proj-stuck)
(list)
(new-proj))) (new-proj)))
((equal c-todo org-x-kw-next) (new-proj :proj-active)) ((equal c-todo org-x-kw-next) (new-proj '(:proj-active)))
((equal c-todo org-x-kw-wait) (new-proj :proj-wait)) ((equal c-todo org-x-kw-wait) (new-proj '(:proj-wait)))
((equal c-todo org-x-kw-hold) (new-proj :proj-hold)) ((equal c-todo org-x-kw-hold) (new-proj '(:proj-hold)))
(t (org-x-dag-bs-error-kw "Task action" c-todo))))))) (t (org-x-dag-bs-error-kw "Task action" c-todo)))))))
(child-bss (child-bss
(org-x-dag-bs-error-kw "Project action" it-todo)) (org-x-dag-bs-error-kw "Project action" it-todo))
@ -3148,29 +3149,33 @@ except it ignores inactive timestamps."
(defun org-x-dag-scan-projects () (defun org-x-dag-scan-projects ()
(cl-flet* (cl-flet*
((format-result ((format-key
(cat result) (id status-data)
(-let* (((&plist :key :status :tags) result) ;; NOTE in the future there might be more than just the car to this
(priority (alist-get status org-x-project-status-priorities))) (let ((status (car status-data)))
(when (>= priority 0) (unless (eq status :proj-complete)
(-> (org-x-dag-format-tag-node cat tags key) (pcase (org-x-dag-id->ns id)
(`(:valid ,v)
(when (plist-get v :committed)
(let ((tags (org-x-dag-id->tags nil id))
(priority (cl-case status
(:proj-active 4)
(:proj-wait 3)
(:proj-hold 2)
(:proj-stuck 1))))
(-> (org-x-dag-format-tag-node tags id)
(org-add-props nil (org-add-props nil
'x-toplevelp (org-x-dag-id->is-toplevel-p key) 'x-toplevelp (org-x-dag-id->is-toplevel-p id)
'x-status status 'x-status status
'x-priority priority))))) 'x-priority priority))))))))))
(format-key (with-temp-buffer
(cat key) (org-mode)
(let ((tags (org-x-dag-id->tags nil key))) (->> (org-x-dag->action-files)
;; TODO don't hardcode these things (org-x-dag-files->ids)
(unless (or (not (eq (cadr (org-x-dag-id->goal-status 'current key)) :planned)) (--map (pcase (org-x-dag-id->bs it)
(org-x-dag-id->is-iterator-p key)) (`(:valid (:sp-proj . ,s))
(-some->> (org-x-dag-id->buffer-children key) (format-key it s))))
(org-x-dag-headline-get-project-status key tags) (-non-nil)))))
(--map (format-result cat it)))))))
(org-x-dag-with-files (org-x-dag->action-files)
(and (org-x-dag-id->is-toplevel-p it)
(not (org-x-dag-id->is-done-p it)))
(format-key it-category it))))
(defun org-x-dag--item-add-goal-ids (item ids) (defun org-x-dag--item-add-goal-ids (item ids)
(if ids (if ids