diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-28 22:36:51 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-28 22:36:51 +0100 |
commit | 22c56dee9b9a1d68c15ba395b223cad2900a8ebf (patch) | |
tree | 68ed913eff692c53e0f7136dba78ca9ba654027a | |
parent | 467933483cc53febf2ff57a6eaaae9e9b19095d6 (diff) |
fix formatting for amounts; better blocked/holiday
-rw-r--r-- | templates/plan-template.t | 13 | ||||
-rw-r--r-- | templates/report.t | 14 | ||||
-rw-r--r-- | zeitgeist.go | 37 |
3 files changed, 45 insertions, 19 deletions
diff --git a/templates/plan-template.t b/templates/plan-template.t index d711f01..a5e29e6 100644 --- a/templates/plan-template.t +++ b/templates/plan-template.t @@ -1,6 +1,9 @@ -# Days -{{- $tl := .Timeline }} -{{ range .Days }} -{{ if .IsWeekend }}# {{end}}{{.Date}}{{ if .IsWeekend }} weekend{{ end -}} -{{ with $e := index $tl .Date }} {{ printf "%8s" $e.Total.AsDay }} {{ printf "%8s" $e.WPs }} {{ end }} +# Entry Format: +# 2006-01-02 WP2:wallet 8h Code Audit +{{- $tl := .Timeline -}} +{{ range .Days 2024 }} +{{ if or .IsWeekend .Holiday .Blocked }}# {{end}}{{.Date}} +{{- with .Holiday }} ({{ . }}){{ end -}} +{{- with .Blocked }} ({{ . }}){{ end -}} +{{/* with $e := index $tl .Date }} {{ printf "%8s" $e.WPs }} {{ printf "%8s" $e.Total.AsDay }}{{ end */}} {{- end }} diff --git a/templates/report.t b/templates/report.t index 679c9e6..1f6de14 100644 --- a/templates/report.t +++ b/templates/report.t @@ -8,11 +8,11 @@ Beneficiary: {{.Beneficiary}} # Planning -Budgeted : {{ $totals.Budgeted }} - Planned : {{ $totals.Planned }}{{with $totals.Unaccounted}} - ! Open !: {{ . }}{{end}} - Done : {{ $totals.Done }}{{ with $totals.Open }} - ! Todo !: {{ . }}{{end}} +Budgeted : {{ printf "%8s" $totals.Budgeted }} + Planned : {{ printf "%8s" $totals.Planned }}{{with $totals.Unaccounted}} + ! Open !: {{ printf "%8s" . }}{{end}} + Done : {{ printf "%8s" $totals.Done }}{{ with $totals.Open }} + ! Todo !: {{ printf "%8s" . }}{{end}} {{ range .ParallelWPTotals }}{{.}} {{ end }} @@ -21,12 +21,12 @@ Budgeted : {{ $totals.Budgeted }} Total for {{ $wp }}: - Budgeted: {{ printf "%8s" $t.Budgeted.AsDay }} - Planned: {{ printf "%8s" $t.Planned.AsDay }}{{with $t.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} - - Actual: {{ printf "%8s" $t.Done.AsDay }}{{with $t.Open }} !TODO: {{printf "%8s" .AsDay }}{{end}} + - Actual: {{ printf "%8s" $t.Done.AsDay }}{{with $t.Open }} !Todo!: {{printf "%8s" .AsDay }}{{end}} - Per Task: {{- range $n, $t := $t.Tasks }} - {{ $n }}:{{ $tt := $p.TotalWPTask $wp $n }} - Budgeted: {{ printf "%8s" $tt.Budgeted.AsDay }} - Planned: {{ printf "%8s" $tt.Planned.AsDay }}{{with $tt.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} - - Actual: {{ printf "%8s" $tt.Done.AsDay }}{{with $tt.Open }} !TODO: {{printf "%8s" .AsDay}}{{end}} + - Actual: {{ printf "%8s" $tt.Done.AsDay }}{{with $tt.Open }} !Todo!: {{printf "%8s" .AsDay}}{{end}} {{ end }} {{ end }} diff --git a/zeitgeist.go b/zeitgeist.go index 12299c8..c77b970 100644 --- a/zeitgeist.go +++ b/zeitgeist.go @@ -40,7 +40,7 @@ type Project struct { Planning string Workpackages map[string]Workpackage Holidays map[Date]string - Blocked Timeline + Blocked map[Date]string Timeline Timeline Planned Timeline Today Date @@ -184,7 +184,7 @@ const ( ) func (u Amount) String() string { - if u < 1 { + if u*u < 1 { return "0" } r := "" @@ -194,9 +194,18 @@ func (u Amount) String() string { if m != 0 { r = fmt.Sprintf("%dM", m) d -= DaysInMonth * m + if d < 0 { + d = -d + } + if h < 0 { + h = -h + } } if d != 0 { r += fmt.Sprintf("%dd", d) + if h < 0 { + h = -h + } } if h != 0 { r += fmt.Sprintf("%dh", h) @@ -524,9 +533,10 @@ func (p *Project) readTimelogs(dir string) error { defer f.Close() scanner := bufio.NewScanner(f) - nr := 1 + nr := 0 last := time.Time{} for scanner.Scan() { + nr += 1 // # Ignore line // # Tab-separated fields // 2024-12-11 wp2:short 8h [comment] @@ -535,7 +545,7 @@ func (p *Project) readTimelogs(dir string) error { continue } - parts := min2w.Split(scanner.Text(), 3) + parts := min2w.Split(scanner.Text(), 4) d, e := time.Parse(time.DateOnly, parts[0]) if e != nil { @@ -586,7 +596,6 @@ func (p *Project) readTimelogs(dir string) error { entries = append(entries, entry) p.Timeline[Date(d)] = entries - nr += 1 } } return nil @@ -626,7 +635,8 @@ type FullDate struct { Planned Entries Worked Entries IsWorkday bool - IsHoliday bool + Holiday string + Blocked string } func (fd *FullDate) IsWeekend() bool { @@ -638,6 +648,11 @@ func (p *Project) IsHoliday(d Date) bool { return ok } +func (p *Project) IsBlocked(d Date) bool { + _, ok := p.Blocked[d] + return ok +} + func (f *FullDate) Difference() Amount { return f.Planned.Total() - f.Worked.Total() } @@ -702,12 +717,20 @@ func (p *Project) Days(ymd ...int) []FullDate { Planned: p.Planned[d], Worked: p.Timeline[d], IsWorkday: d.IsWorkday(), - IsHoliday: p.IsHoliday(d), + Holiday: p.Holidays[d], + Blocked: p.Blocked[d], }) } return dates } +type FullDates []FullDate + +func (f *FullDates) FilterUser(user string) *FullDates { + // TODO + return f +} + func (p *Project) monthCal(year, month int) []string { /* 2 9 16 23 30 |