TASK SPRINT PLANNING 2

This commit is contained in:
Ine Maria Nilssen Aanonsen
2026-03-11 14:54:14 +01:00
parent 3e8d0dc6c6
commit c78b5082d2
13 changed files with 88 additions and 15 deletions

View File

@@ -48,6 +48,7 @@ func (t *SprintPlanningTask) Questions(interfaceType InterfaceType) Questions {
return BaseQuestions(interfaceType).With(
huh.NewGroup(
huh.NewSelect[int]().
Key("sprint-planning-selected-issues").
Title("How many issues did you select for the sprint?").
Options(
huh.NewOption("2-3 issues", 1),
@@ -58,6 +59,10 @@ func (t *SprintPlanningTask) Questions(interfaceType InterfaceType) Questions {
)
}
func (t *SprintPlanningTask) QuestionnaireKeys(_ InterfaceType) []string {
return []string{"task_completed", "task_difficulty", "sprint-planning-selected-issues"}
}
func (t *SprintPlanningTask) Setup(ctx context.Context) error {
if err := ClearIssues(t.app); err != nil {
return err
@@ -116,6 +121,50 @@ func (t *SprintPlanningTask) Setup(ctx context.Context) error {
func (t *SprintPlanningTask) Validate(ctx context.Context) ValidationFeedback {
expect := check.NewExpector()
return expect.Complete()
issues, err := FetchIssues(ctx, t.app, t.setupIssue)
if err != nil {
return expect.ValidationFeedback
}
if len(issues) == 0 {
expect.Fail("No backlog issues found to plan a sprint with.")
return expect.ValidationFeedback
}
// Sort by priority ascending (0 is highest priority).
sorted := make([]*models.Issue, len(issues))
copy(sorted, issues)
for i := 0; i < len(sorted); i++ {
for j := i + 1; j < len(sorted); j++ {
if sorted[j].Priority < sorted[i].Priority {
sorted[i], sorted[j] = sorted[j], sorted[i]
}
}
}
topN := 5
if len(sorted) < topN {
topN = len(sorted)
}
top := sorted[:topN]
var plannedCount int
var readyToSprintCount int
for _, issue := range top {
if issue.Status == models.StatusReadyToSprint ||
issue.Status == models.StatusInProgress ||
issue.Status == models.StatusClosed {
plannedCount++
}
if issue.Status == models.StatusReadyToSprint {
readyToSprintCount++
}
}
expect.Assert(plannedCount >= 3,
"Expected at least 3 of the 5 highest-priority issues to be moved into 'ready_to_sprint', 'in_progress', or 'closed' for the sprint.")
expect.Assert(readyToSprintCount >= 1,
"Expected at least one of the highest-priority issues to be marked as 'ready_to_sprint' to indicate it is planned for the sprint.")
return expect.Complete()
}