ADD logic to tell if iterators need to be refilled (oops)

This commit is contained in:
Nathan Dwarshuis 2022-05-27 21:36:04 -04:00
parent 7a3532ed90
commit 582e938e50
1 changed files with 36 additions and 12 deletions

View File

@ -62,6 +62,12 @@
(defun org-x-dag-time-is-archivable-p (epochtime) (defun org-x-dag-time-is-archivable-p (epochtime)
(< (* 60 60 24 org-x-archive-delay) (- (float-time) epochtime))) (< (* 60 60 24 org-x-archive-delay) (- (float-time) epochtime)))
;; org ml wrappers
(defun org-x-dag-timestamp-to-epoch (ts)
(->> (org-ml-timestamp-get-start-time ts)
(org-ml-time-to-unixtime)))
;; calendar interface ;; calendar interface
(defun org-x-dag-gregorian-to-date (greg) (defun org-x-dag-gregorian-to-date (greg)
@ -3023,16 +3029,31 @@ FUTURE-LIMIT in a list."
(list)))))))))) (list))))))))))
(defun org-x-dag-itemize-iterators (files) (defun org-x-dag-itemize-iterators (files)
(cl-flet
((get-status
(data)
(pcase data
(`(:iter-empty) :empty)
(`(:iter-active ,data)
(-let* (((&plist :dead d :sched s) data)
(d* (-some->> d (org-x-dag-timestamp-to-epoch)))
(s* (-some->> s (org-x-dag-timestamp-to-epoch))))
(-if-let (epoch (if (and d* s*) (min d* s*) (or s* d*)))
(if (< (+ (float-time) org-x-iterator-active-future-offset)
epoch)
:active
:refill)
:unknown)))
(`(:iter-complete ,_) :complete))))
(org-x-dag-with-unmasked-action-ids files (org-x-dag-with-unmasked-action-ids files
(pcase it-local (pcase it-local
(`(:sp-iter . ,status-data) (`(:sp-iter . ,status-data)
(let ((status (car status-data))) (let ((status (get-status status-data))
(when (memq status '(:iter-empty :iter-active)) (tags (org-x-dag-id->tags it)))
(let ((tags (org-x-dag-id->tags it)))
(-> (org-x-dag-format-tag-node tags it) (-> (org-x-dag-format-tag-node tags it)
(org-add-props nil (org-add-props nil
'x-status status) 'x-status status)
(list))))))))) (list))))))))
(defun org-x-dag-itemize-incubated (files) (defun org-x-dag-itemize-incubated (files)
(org-x-dag-with-unmasked-action-ids files (org-x-dag-with-unmasked-action-ids files
@ -5041,8 +5062,11 @@ review phase)"
(lambda (line) (lambda (line)
(let ((s (get-text-property 1 'x-status line))) (let ((s (get-text-property 1 'x-status line)))
(pcase s (pcase s
(:iter-empty "1. Empty") (:unknown "0. Unknown")
(:iter-active "2. Active"))))))))))) (:complete "1. Refill")
(:empty "2. Empty")
(:refill "3. Refill")
(:active "4. Active")))))))))))
(defun org-x-dag-agenda-errors () (defun org-x-dag-agenda-errors ()
"Show the critical errors agenda view." "Show the critical errors agenda view."