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)
(org-add-props nil (`(:valid ,v)
'x-toplevelp (org-x-dag-id->is-toplevel-p key) (when (plist-get v :committed)
'x-status status (let ((tags (org-x-dag-id->tags nil id))
'x-priority priority))))) (priority (cl-case status
(format-key (:proj-active 4)
(cat key) (:proj-wait 3)
(let ((tags (org-x-dag-id->tags nil key))) (:proj-hold 2)
;; TODO don't hardcode these things (:proj-stuck 1))))
(unless (or (not (eq (cadr (org-x-dag-id->goal-status 'current key)) :planned)) (-> (org-x-dag-format-tag-node tags id)
(org-x-dag-id->is-iterator-p key)) (org-add-props nil
(-some->> (org-x-dag-id->buffer-children key) 'x-toplevelp (org-x-dag-id->is-toplevel-p id)
(org-x-dag-headline-get-project-status key tags) 'x-status status
(--map (format-result cat it))))))) 'x-priority priority))))))))))
(org-x-dag-with-files (org-x-dag->action-files) (with-temp-buffer
(and (org-x-dag-id->is-toplevel-p it) (org-mode)
(not (org-x-dag-id->is-done-p it))) (->> (org-x-dag->action-files)
(format-key it-category it)))) (org-x-dag-files->ids)
(--map (pcase (org-x-dag-id->bs it)
(`(:valid (:sp-proj . ,s))
(format-key it s))))
(-non-nil)))))
(defun org-x-dag--item-add-goal-ids (item ids) (defun org-x-dag--item-add-goal-ids (item ids)
(if ids (if ids