Introduce first draft to compute time spent on work today
This is supposed to be used later on in workload overview reports, to make the display of the current day account for already spent time.
This commit is contained in:
parent
9e3fe2a3b0
commit
2b02f45a1b
@ -847,6 +847,32 @@ PARAMS is a property list of the following parameters:
|
|||||||
(org-dynamic-block-define "db/org-workload-overview-report"
|
(org-dynamic-block-define "db/org-workload-overview-report"
|
||||||
#'db/org-insert-workload-overview-report)
|
#'db/org-insert-workload-overview-report)
|
||||||
|
|
||||||
|
(defun db/spent-work-hours-today (&optional match)
|
||||||
|
"Return the time spent today on work.
|
||||||
|
|
||||||
|
The result is given as integer in minutes.
|
||||||
|
|
||||||
|
MATCH is a Org properties match that determines what constitutes
|
||||||
|
as work item. When not given, defaults to all tasks except those
|
||||||
|
given by `org-home-task-id' and `org-break-task-id'."
|
||||||
|
(unless match
|
||||||
|
(setq match "")
|
||||||
|
(when (and (stringp org-home-task-id)
|
||||||
|
(not (zerop (length org-home-task-id))))
|
||||||
|
(setq match (concat match (format "-ID=%s" org-home-task-id))))
|
||||||
|
(when (and (stringp org-break-task-id)
|
||||||
|
(not (zerop (length org-break-task-id))))
|
||||||
|
(setq match (concat match (format "-ID=%s" org-break-task-id)))))
|
||||||
|
(->> org-agenda-files
|
||||||
|
(-map #'(lambda (file) ; taken from `org-dblock-write:clocktable'
|
||||||
|
(with-current-buffer (find-buffer-visiting file)
|
||||||
|
(save-excursion
|
||||||
|
(save-restriction
|
||||||
|
(org-clock-get-table-data file (list :match match
|
||||||
|
:block 'today)))))))
|
||||||
|
(-map #'cl-second)
|
||||||
|
-sum))
|
||||||
|
|
||||||
|
|
||||||
;;; Fixes
|
;;; Fixes
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user