Commit b5be13ecf1b01bf5dd5e67f0eebaca7c11e6635a

Authored by Georg Hopp
1 parent ba3541b9

Fix display when no times are tracked for now

@@ -31,14 +31,14 @@ function uuids() { @@ -31,14 +31,14 @@ function uuids() {
31 function worktimes() { 31 function worktimes() {
32 [[ $# -eq 0 ]] && return 1 32 [[ $# -eq 0 ]] && return 1
33 33
34 - local WHEN='\([^ ]*\) \([^ ]*\)'  
35 - local DUR='.*duration: \(\([0-9]*\)d \)\?\([^)]*\)'  
36 - local OUT='{"uuid":"'"$1"'","stop":"\1T\2Z","duration":"\4:\5"}' 34 + local PWHEN='\([^ ]*\) \([^ ]*\)'
  35 + local PDUR='.*duration: \(\([0-9]*\)d \)\?\([^)]*\)'
  36 + local POUT='{"uuid":"'"$1"'","stop":"\1T\2Z","duration":"\4:\5"}'
37 local TIME DAYS 37 local TIME DAYS
38 38
39 echo '[' 39 echo '['
40 task $1 info|\ 40 task $1 info|\
41 - sed 's/'"${WHEN}${DUR}"'.*/'"${OUT}"'/;te;d;:e'|\ 41 + sed 's/'"${PWHEN}${PDUR}"'.*/'"${POUT}"'/;te;d;:e'|\
42 while read TIME; do 42 while read TIME; do
43 DUR="$(echo "${TIME}"|jq -r '.duration')" 43 DUR="$(echo "${TIME}"|jq -r '.duration')"
44 DAYS="${DUR%%:*}" 44 DAYS="${DUR%%:*}"
@@ -69,6 +69,9 @@ function work() { @@ -69,6 +69,9 @@ function work() {
69 done 69 done
70 done 70 done
71 71
  72 + DAYS=${DAYS:-0}
  73 + SECS=${SECS:-0}
  74 +
72 printf '{"uuid":"%s","times":%s,"total":"%s:%s"}'\ 75 printf '{"uuid":"%s","times":%s,"total":"%s:%s"}'\
73 ${UUID} "${TIMES}" ${DAYS} $(date +%H:%M:%S -u -d@${SECS}) 76 ${UUID} "${TIMES}" ${DAYS} $(date +%H:%M:%S -u -d@${SECS})
74 } 77 }
@@ -79,6 +82,9 @@ function flattened_work() { @@ -79,6 +82,9 @@ function flattened_work() {
79 WORK="$(work $1)" 82 WORK="$(work $1)"
80 ITEM="$(echo "${WORK}"|jq -M -c '.|del(.times)')" 83 ITEM="$(echo "${WORK}"|jq -M -c '.|del(.times)')"
81 84
  85 + # If there are no TIMES logged then this will be empty at all.
  86 + # The only remaining information in that case would have been the
  87 + # UUID. But the caller already know it.
82 echo "${WORK}"|jq -M -c '.times|map(.+'"${ITEM}"')' 88 echo "${WORK}"|jq -M -c '.times|map(.+'"${ITEM}"')'
83 } 89 }
84 90
@@ -27,7 +27,7 @@ function showall() { @@ -27,7 +27,7 @@ function showall() {
27 eval set -- ${W} 27 eval set -- ${W}
28 28
29 if [[ ${NO} -eq 1 ]]; then 29 if [[ ${NO} -eq 1 ]]; then
30 - local TIME="$(formattime $4)" 30 + local TIME="$(formattime ${4:-0:00:00:00})"
31 local PROJECT="$(task _get $UUID.project)" 31 local PROJECT="$(task _get $UUID.project)"
32 32
33 printf "%-10.10s %-33.33s %s %-10.10s %-10.10s\n" \ 33 printf "%-10.10s %-33.33s %s %-10.10s %-10.10s\n" \
@@ -38,14 +38,16 @@ function showall() { @@ -38,14 +38,16 @@ function showall() {
38 "$(todate $(task _get $UUID.entry))" 38 "$(todate $(task _get $UUID.entry))"
39 fi 39 fi
40 40
41 - if [[ ${NO} -eq ${UNITS} ]]; then  
42 - printf "└─ %s %13.13s\n" \  
43 - "$(timestring "$1" "$2")" \  
44 - "$(formattime $2)"  
45 - else  
46 - printf "├─ %s %13.13s\n" \  
47 - "$(timestring "$1" "$2")" \  
48 - "$(formattime $2)" 41 + if [[ $# -ne 0 ]]; then
  42 + if [[ ${NO} -eq ${UNITS} ]]; then
  43 + printf "└─ %s %13.13s\n" \
  44 + "$(timestring "$1" "$2")" \
  45 + "$(formattime $2)"
  46 + else
  47 + printf "├─ %s %13.13s\n" \
  48 + "$(timestring "$1" "$2")" \
  49 + "$(formattime $2)"
  50 + fi
49 fi 51 fi
50 NO=$((NO+1)) 52 NO=$((NO+1))
51 done 53 done
@@ -90,7 +92,7 @@ function timesheet() { @@ -90,7 +92,7 @@ function timesheet() {
90 "${TODAY}" \ 92 "${TODAY}" \
91 "$(bold "" "Tasks completed from $START to $TODAY (back $PHRASE)")" \ 93 "$(bold "" "Tasks completed from $START to $TODAY (back $PHRASE)")" \
92 "${DONE}" \ 94 "${DONE}" \
93 - "$(bold "" "Upcoming tasks")" \ 95 + "$(bold "" "Current tasks")" \
94 "${UPCOMING}" \ 96 "${UPCOMING}" \
95 "$(bold "" "Blocked tasks")" \ 97 "$(bold "" "Blocked tasks")" \
96 "${BLOCKED}" \ 98 "${BLOCKED}" \
Please register or login to post a comment