-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.go
87 lines (76 loc) · 1.96 KB
/
print.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"fmt"
"strings"
"time"
)
func getNotesHeader(path string) ([]byte, error) {
today := time.Now()
weekday := string([]byte(today.Weekday().String())[:3])
kitchen := today.Format("03:04 PM")
zone, _ := today.Zone()
taskList, err := getLastTaskList(path)
if err != nil {
return nil, err
}
return []byte(fmt.Sprintf("# %s %02d, %04d\n\nToday is a beautiful day.%s\n\n## %04d-%02d-%02d %s %s %s (admin)\n\n\n",
today.Month(),
today.Day(),
today.Year(),
taskList,
today.Year(),
today.Month(),
today.Day(),
weekday,
kitchen,
zone,
)), nil
}
func getSummary(t *totals) string {
return fmt.Sprintf(`
This week you have worked: %s
Today you have worked: %s
Productivity: %.1f%%, %.1f%%, %.1f%%
%s
%s
`,
minToHourMin(t.weekTotalMinutes()),
minToHourMin(t.nDayTotalMinutes(1)),
t.nDayProductivePercent(1),
t.nDayProductivePercent(5),
t.nDayProductivePercent(15),
t.summaryCategories(),
t.summaryFooter())
}
func (t *totals) summaryCategories() string {
themeTotals := make(map[string]int)
// first get all categories since start of week
for i := 0; i <= t.sowIndex; i++ {
for _, category := range sortedKeys(t.days[i]) {
theme := strings.Split(category, ", ")[0]
themeTotals[theme] = 0
}
}
// this is getting the totals for the current day
for _, category := range sortedKeys(t.days[0]) {
theme := strings.Split(category, ", ")[0]
themeTotals[theme] += t.days[0][category]
}
summaryCategories := ""
for _, theme := range t.sortedKeysByThemePercentage(themeTotals) {
summaryCategories += fmt.Sprintf(" ➔ %s: %s (%.1f%%, %.1f%%, %.1f%%)\n",
theme,
minToHourMin(themeTotals[theme]),
t.nDayThemePercent(1, theme),
t.nDayThemePercent(5, theme),
t.nDayThemePercent(15, theme))
}
return summaryCategories
}
func (t *totals) summaryFooter() string {
if t.current != "" {
return fmt.Sprintf("You are currently working on: %s", t.current)
} else {
return "You are not currently tracking any work."
}
}