FIX a bunch of project errors

This commit is contained in:
Nathan Dwarshuis 2022-04-02 23:18:02 -04:00
parent 8cc48bb484
commit 92b8639327
1 changed files with 65 additions and 45 deletions

View File

@ -1454,7 +1454,8 @@ used for optimization."
(defmacro org-x-dag-bs-fold-children (bss default rank-form stop-form trans-form) (defmacro org-x-dag-bs-fold-children (bss default rank-form stop-form trans-form)
(declare (indent 2)) (declare (indent 2))
(let ((err (org-x-dag-bs :error "Child error"))) (let ((err (org-x-dag-bs :error "Child error")))
`(-if-let ((x . xs) ,bss) `(if ,bss
(-let (((x . xs) ,bss))
;; (if (org-x-dag-bs-error-p x) (progn (print x) ',err) ;; (if (org-x-dag-bs-error-p x) (progn (print x) ',err)
(if (org-x-dag-bs-error-p x) ',err (if (org-x-dag-bs-error-p x) ',err
(let ((acc (cadr x)) r final) (let ((acc (cadr x)) r final)
@ -1475,7 +1476,7 @@ used for optimization."
(!cdr xs))))) (!cdr xs)))))
(when (not final) (when (not final)
(setq final (org-x-dag-bs :valid acc))) (setq final (org-x-dag-bs :valid acc)))
(org-x-dag-bs>>= final ,trans-form))) (org-x-dag-bs>>= final ,trans-form))))
(org-x-dag-bs :valid ,default)))) (org-x-dag-bs :valid ,default))))
(defun org-x-dag-bs-error-kw (type-name kw) (defun org-x-dag-bs-error-kw (type-name kw)
@ -1516,7 +1517,11 @@ used for optimization."
(cl-flet (cl-flet
((new-proj ((new-proj
(status) (status)
(org-x-dag-bs :valid `(:sp-proj ,@status)))) (org-x-dag-bs :valid `(:sp-proj ,@status)))
(is-next
(task-data)
(-let (((&plist :todo :sched) task-data))
(or sched (equal todo org-x-kw-next)))))
;; rankings ;; rankings
;; *-active > proj-wait > proj-held > (proj-stuck == iter-empty) > *-complete ;; *-active > proj-wait > proj-held > (proj-stuck == iter-empty) > *-complete
(org-x-dag-bs-action-with-closed node-data "projects" (org-x-dag-bs-action-with-closed node-data "projects"
@ -1558,22 +1563,38 @@ used for optimization."
:dead dead) :dead dead)
(list :sp-task :task-active)))) (list :sp-task :task-active))))
(cond (cond
((equal it-todo org-x-kw-hold) ((and child-bss (equal it-todo org-x-kw-hold))
(new-proj '(:proj-held))) (new-proj '(:proj-held)))
((and sched child-bss) ((and child-bss sched)
(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)
(org-x-dag-bs-fold-children child-bss task-default (org-x-dag-bs-fold-children child-bss task-default
(->> (pcase `(,acc ,it) (->> (pcase `(,acc ,it)
(`((:sp-task :task-active ,a) (:sp-task :task-active ,b)) (`((:sp-task :task-active ,a) (:sp-task :task-active ,b))
(and (not (plist-get a :sched)) (plist-get b :sched))) (and (not (is-next a)) (is-next b)))
(`(,(or `(:sp-proj :proj-active)
`(:sp-proj :proj-wait)
`(:sp-proj :proj-held)
`(:sp-proj :proj-stuck)
`(:sp-iter :iter-active)
`(:sp-iter :iter-empty))
(:sp-task :task-active ,d))
(is-next d))
(`((:sp-task :task-active ,d)
,(or `(:sp-proj :proj-active)
`(:sp-proj :proj-wait)
`(:sp-proj :proj-held)
`(:sp-proj :proj-stuck)
`(:sp-iter :iter-active)
`(:sp-iter :iter-empty)))
(not (is-next d)))
(`((:sp-proj :proj-active) ,_) nil)
(`((:sp-iter :iter-active ,_) ,_) nil) (`((:sp-iter :iter-active ,_) ,_) nil)
(`((:sp-task :task-active ,d) ,_) (not (plist-get d :sched))) (`((:sp-proj :proj-active) ,_) nil)
(`(,_ (:sp-proj :proj-active)) t) (`(,_ (:sp-proj :proj-active)) t)
(`(,_ (:sp-iter :iter-active ,_)) t) (`(,_ (:sp-iter :iter-active ,_)) t)
(`(,_ (:sp-task :task-active ,d)) (plist-get d :sched))
(`((:sp-proj :proj-wait) ,_) nil) (`((:sp-proj :proj-wait) ,_) nil)
(`(,_ (:sp-proj :proj-wait)) t) (`(,_ (:sp-proj :proj-wait)) t)
@ -1583,8 +1604,10 @@ used for optimization."
(`((:sp-proj :proj-stuck) ,_) nil) (`((:sp-proj :proj-stuck) ,_) nil)
(`((:sp-iter :iter-empty) ,_) nil) (`((:sp-iter :iter-empty) ,_) nil)
(`((:sp-task :task-active ,_) ,_) nil)
(`(,_ (:sp-proj :proj-stuck)) t) (`(,_ (:sp-proj :proj-stuck)) t)
(`(,_ (:sp-iter :iter-empty)) t) (`(,_ (:sp-iter :iter-empty)) t)
(`(,_ (:sp-task :task-active ,_)) t)
;; any pair that makes it this far is completed in both, which means ;; any pair that makes it this far is completed in both, which means
;; neither takes precedence, which means choose the left one ;; neither takes precedence, which means choose the left one
@ -1595,7 +1618,7 @@ used for optimization."
(pcase acc (pcase acc
(`(:sp-proj :proj-active) t) (`(:sp-proj :proj-active) t)
(`(:sp-iter :iter-active ,_) t) (`(:sp-iter :iter-active ,_) t)
(`(:sp-task :task-active ,d) (plist-get d :sched)) (`(:sp-task :task-active ,d) (is-next d))
(_ nil)) (_ nil))
;; child -> parent translation ;; child -> parent translation
@ -3158,6 +3181,7 @@ except it ignores inactive timestamps."
(id status-data) (id status-data)
;; NOTE in the future there might be more than just the car to this ;; NOTE in the future there might be more than just the car to this
(let ((status (car status-data))) (let ((status (car status-data)))
(print status)
(-when-let (priority (cl-case status (-when-let (priority (cl-case status
(:proj-active 4) (:proj-active 4)
(:proj-wait 3) (:proj-wait 3)
@ -3477,21 +3501,17 @@ except it ignores inactive timestamps."
(defun org-x-dag-scan-errors () (defun org-x-dag-scan-errors ()
(cl-flet (cl-flet
((format-id ((format-id
(category id) (id msg)
(-when-let (error-type (-> (org-x-dag-format-tag-node nil id)
(if (org-x-dag-id->is-iterator-p id)
(unless (org-x-dag-id->node-property "ARCHIVE" id)
:missing-archive)
(-if-let (created (org-x-dag-id->node-property org-x-prop-created))
(when (<= (float-time) (org-2ft created))
:future-created)
:missing-created)))
(-> (org-x-dag-format-tag-node category nil id)
(org-add-props nil (org-add-props nil
'x-error error-type))))) 'x-error msg))))
(org-x-dag-with-files (org-x-dag->files) (with-temp-buffer
(not (org-x-dag-id->is-done-p it)) (org-mode)
(list (format-id it-category it))))) (->> (org-x-dag->action-files)
(org-x-dag-files->ids)
(--map (pcase (org-x-dag-id->bs it)
(`(:error ,msg) (format-id it msg))))
(-non-nil)))))
(defun org-x-dag-scan-agenda (sel-date) (defun org-x-dag-scan-agenda (sel-date)
(cl-flet* (cl-flet*