Convert active timestamps in workload report into inactive ones

Otherwise, agenda views get mixed up.
This commit is contained in:
Daniel - 2022-09-10 09:55:55 +02:00
parent e5bad8b847
commit 257c2c815d
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 23 additions and 16 deletions

View File

@ -475,22 +475,29 @@ understood by `org-read-date'."
(otherwise (user-error ":sort-column value invalid, see docstring of `org-dblock-write:db/org-workload-report' for options")))) (otherwise (user-error ":sort-column value invalid, see docstring of `org-dblock-write:db/org-workload-report' for options"))))
(task-summary (db/org-planned-tasks-in-range start-date end-date org-ql-match))) (task-summary (db/org-planned-tasks-in-range start-date end-date org-ql-match)))
(insert "| Task | Effort | Timestamp | SCHEDULED | DEADLINE |\n|---|\n") ;; Create table
(pcase-dolist (`(,task-id . ,effort-string) (cdr task-summary)) (cl-flet ((ts-property-from-id (task-id property)
(insert (format "| %s | %s | %s | %s | %s |\n" ;; Retrieve PROPERTY from task given by TASK-ID. If found,
(db/org--format-link-from-org-id task-id) ;; assume PROPERTY to be a timestamp and unconditionally convert
(or effort-string "") ;; it into an inactive timestamp. If PROPERTY is not found,
(or (org-entry-get (org-id-find task-id 'marker) ;; return the empty string.
"TIMESTAMP") (--if-let (org-entry-get (org-id-find task-id 'marker)
"") property)
(or (org-entry-get (org-id-find task-id 'marker) (concat "[" (substring it 1 -1) "]")
"SCHEDULED") "")))
"")
(or (org-entry-get (org-id-find task-id 'marker) (insert "| Task | Effort | Timestamp | SCHEDULED | DEADLINE |\n|---|\n")
"DEADLINE") (pcase-dolist (`(,task-id . ,effort-string) (cdr task-summary))
"")))) (insert (format "| %s | %s | %s | %s | %s |\n"
(insert (format "|---|\n| Total | %s |\n|---|" (car task-summary))) (db/org--format-link-from-org-id task-id)
(org-table-align) (or effort-string "")
(ts-property-from-id task-id "TIMSTAMP")
(ts-property-from-id task-id "SCHEDULED")
(ts-property-from-id task-id "DEADLINE"))))
(insert (format "|---|\n| Total | %s |\n|---|" (car task-summary)))
(org-table-align))
;; Sort table
(forward-line -4) ; go back to actual data (forward-line -4) ; go back to actual data
(beginning-of-line) (beginning-of-line)
(dotimes (_ sort-column-count) ; move to column to sort (dotimes (_ sort-column-count) ; move to column to sort