Skip to content

Commit

Permalink
[#403] Use template file for building retrospective contents
Browse files Browse the repository at this point in the history
- Add retro/template/retro.md
- Import template file using embed
  • Loading branch information
mengdaming committed Oct 22, 2024
1 parent 03515d7 commit cd5699f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/engine/tcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (tcr *TCREngine) PrintStats(p params.Params) {
}

// GenerateRetro generates a retrospective markdown file template using stats
func (tcr *TCREngine) GenerateRetro(_p params.Params) {
func (tcr *TCREngine) GenerateRetro(_ params.Params) {
//TODO implement me
panic("implement me")
}
Expand Down
11 changes: 7 additions & 4 deletions src/retro/retrospective.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@ package retro

import (
"bytes"
_ "embed"
"github.com/murex/tcr/events"
"text/template"
)

//go:embed template/retro.md
var tmpl string

// GenerateMarkdown builds retrospective markdown contents
func GenerateMarkdown(tcrEvents *events.TcrEvents) string {
t := template.New("QuickRetro")
t, _ = t.Parse("# Quick Retrospective\n" +
"Average passed commit size: {{.GreenAvg}}\n" +
"Average failed commit size: {{.RedAvg}}\n")
t, _ = t.Parse(tmpl)

greenAvg := tcrEvents.AllLineChangesPerGreenCommit().Avg()
redAvg := tcrEvents.AllLineChangesPerRedCommit().Avg()

buf := new(bytes.Buffer)
t.Execute(buf, struct {
_ = t.Execute(buf, struct {
GreenAvg any
RedAvg any
}{greenAvg, redAvg})
Expand Down
40 changes: 40 additions & 0 deletions src/retro/template/retro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Quick Retrospective

## TODO - Session Name

| Team | Date |
|------|------------|
| XXX | MM/DD/YYYY |

## Session's TCR metrics

- Average passed commit size: {{.GreenAvg}}
- Average failed commit size: {{.RedAvg}}

## DO

_`What did we do?`_

-
-

## LEARN

_`What did we learn?`_

-
-

## PUZZLE

_`What still puzzles us?`_

-
-

## DECIDE

_`How can we apply this in the future?`_

-
-

0 comments on commit cd5699f

Please sign in to comment.