Compare commits

..

2 Commits

Author SHA1 Message Date
bdfcc61dd2
Refactor and simplify work hour computation in overview report
This is to prepare a generalization of how to specify work hours, namly
using a function from date to available work hours on that day.
2024-10-03 17:40:46 +02:00
9d03f2d953
Show available work hours in overview report to easy comparison
This is also helpful to plausibilize the shown entries, e.g. checking
whether holidays were accidentally included.
2024-10-03 17:30:56 +02:00

View File

@ -805,29 +805,30 @@ PARAMS is a property list of the following parameters:
(insert (format "#+CAPTION: Workload Overview Report at [%s] with start date [%s]\n" (insert (format "#+CAPTION: Workload Overview Report at [%s] with start date [%s]\n"
(format-time-string timestamp-format (current-time)) (format-time-string timestamp-format (current-time))
(format-time-string timestamp-format start-date))) (format-time-string timestamp-format start-date)))
(insert "| End Time | Planned Total | Utilization |\n| <r> | <r> | <r> |\n|---|\n") (insert "| End Time | Planned Work | Work Hours | Utilization |\n| <r> | <r> | <r> | <r> |\n|---|\n")
;; Compute workload report for each date and record the total time; ;; Compute workload report for each date and record the total time;
;; XXX: this might be slow, try to reduce the calls to `db/org-planned-tasks-in-range'. (let ((total-work-hours 0))
(let ((days 0))
(dolist (interval-end-date date-range) (dolist (interval-end-date date-range)
(let ((total-time (car (db/org-planned-tasks-in-range (let* ((total-time-duration (car ;; XXX: this might be slow, try to reduce the calls to
;; Set start date to nil to also include tasks scheduled or deadlined ;; `db/org-planned-tasks-in-range'.
;; before `start-date', as those are also still open and need to be (db/org-planned-tasks-in-range
;; done somewhen. ;; Set start date to nil to also include tasks scheduled or
nil ;; deadlined before `start-date', as those are also still open
interval-end-date ;; and need to be done somewhen.
org-ql-match)))) nil
(let ((utilization (* (/ (org-duration-to-minutes total-time) interval-end-date
(* (cl-incf days) org-ql-match)))
(org-duration-to-minutes work-hours))) (utilization (* (/ (org-duration-to-minutes total-time-duration)
100))) (cl-incf total-work-hours (org-duration-to-minutes work-hours)))
(insert (format "| [%s] | %s | %s |\n" 100)))
interval-end-date (insert (format "| [%s] | %s | %s | %s |\n"
total-time interval-end-date
(if (<= 80 utilization) total-time-duration
;; When utilization is above 80%, mark entry in bold (org-duration-from-minutes total-work-hours)
(format "*%.2f%%*" utilization) (if (<= 80 utilization)
(format "%.2f%%" utilization)))))))) ;; When utilization is above 80%, mark entry in bold
(format "*%.2f%%*" utilization)
(format "%.2f%%" utilization)))))))
(insert "|--|") (insert "|--|")
(org-table-align))) (org-table-align)))