From 047627c6ac533cc6a7bfc0277a6a5678a33a6353 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 7 Oct 2022 15:42:02 +0200 Subject: [PATCH] Allow no start date in workload overview report This is different from the previous default start date of today, as now all past items will also be considered. Additionally, also include the start date (or today, if not given) to be included in the result table to show all efforts still left for that day. --- site-lisp/db-org.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 0153593..c0519fb 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -534,7 +534,7 @@ PARAMS is a property list of the following parameters: `:start-date': Start date for the workload report. When not provided, will - default to today. When provided, must be in a format + default to no start date. When provided, must be in a format understood by `org-read-date'. `:end-date': @@ -554,19 +554,21 @@ PARAMS is a property list of the following parameters: `org-ql' expression (in sexp syntax) to filter the list of tasks to consider. Defaults to (todo)." (let* ((start-date (or (plist-get params :start-date) - (org-read-date nil nil "."))) + nil)) (end-date (or (plist-get params :end-date) (user-error "No end-date provided"))) (increment (or (plist-get params :increment) "+1d")) (org-ql-match (or (plist-get params :org-ql-match) '(todo))) - (current start-date) + (current (or start-date + (org-read-date nil nil "."))) (date-range nil)) ;; Check input - (unless (string-match-p (org-re-timestamp 'inactive) - (format "[%s]" start-date)) + (unless (or (null start-date) + (string-match-p (org-re-timestamp 'inactive) + (format "[%s]" start-date))) (user-error "Invalid start date given: %s" start-date)) (unless (string-match-p (org-re-timestamp 'inactive) @@ -597,7 +599,7 @@ PARAMS is a property list of the following parameters: ;; this might be slow, try to reduce the calls to ;; `db/org-planned-tasks-in-range'. (insert "| Until | Planned Total |\n| | |\n|---|\n") - (dolist (interval-end-date (cdr date-range)) ; `cdr' is for ignoring the `start-date' itself + (dolist (interval-end-date date-range) (let ((total-time (car (db/org-planned-tasks-in-range start-date interval-end-date org-ql-match))))