Merge pull request #10 from vale981/total_time

display total time worked, braked and tracked
This commit is contained in:
Pavel Korytov 2023-06-02 23:45:40 +03:00 committed by GitHub
commit d05d9cb333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,14 +248,15 @@ return it, otherwise, return a value like a calc error."
('nil 0))) ('nil 0)))
0)) 0))
(defun pomm-third-time--worked-time () (defun pomm-third-time--total-time (&optional kind)
"Get total time worked in the current iteration." "Get total time spent in `state` in the current iteration."
(let ((iteration (alist-get 'iteration (let* ((kind (if kind kind 'work))
(alist-get 'current pomm-third-time--state))) (iteration (alist-get 'iteration
(current-kind (alist-get 'kind (alist-get 'current pomm-third-time--state)))) (alist-get 'current pomm-third-time--state)))
(current-kind (alist-get 'kind (alist-get 'current pomm-third-time--state))))
(apply (apply
#'+ #'+
(if (eq current-kind 'work) (if (eq current-kind kind)
(pomm-third-time--current-period-time) (pomm-third-time--current-period-time)
0) 0)
(mapcar (mapcar
@ -265,9 +266,10 @@ return it, otherwise, return a value like a calc error."
(seq-filter (seq-filter
(lambda (item) (lambda (item)
(and (= (alist-get 'iteration item) iteration) (and (= (alist-get 'iteration item) iteration)
(eq (alist-get 'kind item) 'work))) (eq (alist-get 'kind item) kind)))
(alist-get 'history pomm-third-time--state)))))) (alist-get 'history pomm-third-time--state))))))
(defun pomm-third-time--need-switch-p () (defun pomm-third-time--need-switch-p ()
"Check if the break period has to end." "Check if the break period has to end."
(and (and
@ -536,7 +538,9 @@ KIND is the same as in `pomm-third-time--state'"
(iteration (alist-get 'iteration (iteration (alist-get 'iteration
(alist-get 'current pomm-third-time--state))) (alist-get 'current pomm-third-time--state)))
(break-time (pomm-third-time--break-time)) (break-time (pomm-third-time--break-time))
(period-time (pomm-third-time--current-period-time))) (period-time (pomm-third-time--current-period-time))
(total-work (pomm-third-time--total-time 'work))
(total-break (pomm-third-time--total-time 'break)))
(concat (concat
(format "Iteration #%d. " iteration) (format "Iteration #%d. " iteration)
"State: " "State: "
@ -556,9 +560,17 @@ KIND is the same as in `pomm-third-time--state'"
(propertize (propertize
(pomm-third-time--format-period break-time) (pomm-third-time--format-period break-time)
'face 'success) 'face 'success)
". Total time worked: " ".\nTotal time worked: "
(propertize (propertize
(pomm-third-time--format-period (pomm-third-time--worked-time)) (pomm-third-time--format-period total-work)
'face 'success)
". Total time braked: "
(propertize
(pomm-third-time--format-period total-break)
'face 'success)
". Total time tracked: "
(propertize
(pomm-third-time--format-period (+ total-work total-break))
'face 'success)))))) 'face 'success))))))
(defclass pomm-third-time--transient-history (transient-suffix) (defclass pomm-third-time--transient-history (transient-suffix)