improve task logic

This commit is contained in:
Robin Olsen
2026-03-11 20:35:22 +01:00
parent 3f8629ab32
commit a5b04997a7
2 changed files with 32 additions and 53 deletions

View File

@@ -19,15 +19,14 @@ You need to rebalance the current sprint priorities:
1. Assign the task Issue you are currently reading to yourself as "Me" and set status to "In Progress". 1. Assign the task Issue you are currently reading to yourself as "Me" and set status to "In Progress".
2. A new issue has appeared in the list that needs urgent attention. Change the database related issue's priority to 4 (critical). 2. A new issue has appeared in the list that needs urgent attention. Change the database related issue's priority to 4 (critical).
3. Set the priority of the feature and chore issues in the list to 1 (low). 3. Set the priority of the feature and chore issues in the list to 1 (low).`
4. Change this issue status to "Closed".
`
type PriorityManagementTask struct { type PriorityManagementTask struct {
done bool done bool
app *App app *App
setupIssue *Issue setupIssue *Issue
priorityIssues []*models.Issue
isInProgress bool
} }
func NewPriorityManagementTask(app *App) *PriorityManagementTask { func NewPriorityManagementTask(app *App) *PriorityManagementTask {
@@ -66,7 +65,7 @@ func (t *PriorityManagementTask) Setup(ctx context.Context) error {
return err return err
} }
priorityIssues := []*models.Issue{ t.priorityIssues = []*models.Issue{
NewIssueBuilder(). NewIssueBuilder().
WithTitle("Database connection failures"). WithTitle("Database connection failures").
WithDescription("PRODUCTION CRITICAL: Intermittent DB connection failures affecting all users. Needs immediate attention."). WithDescription("PRODUCTION CRITICAL: Intermittent DB connection failures affecting all users. Needs immediate attention.").
@@ -104,7 +103,7 @@ func (t *PriorityManagementTask) Setup(ctx context.Context) error {
Build(), Build(),
} }
if err := t.app.Issues.CreateIssues(ctx, priorityIssues, ""); err != nil { if err := t.app.Issues.CreateIssues(ctx, t.priorityIssues, ""); err != nil {
return err return err
} }
@@ -121,56 +120,26 @@ func (t *PriorityManagementTask) Validate(ctx context.Context) ValidationFeedbac
issues, err := FetchIssues(ctx, t.app, t.setupIssue) issues, err := FetchIssues(ctx, t.app, t.setupIssue)
if err != nil { if err != nil {
return expect.Fatal("Failed to fetch issues for validation")
}
expect.NotEmptyAndEqual(t.setupIssue.Assignee, "Me",
fmt.Sprintf("%s assignee", t.setupIssue.Title))
expect.Equal(t.setupIssue.Status, models.StatusInProgress,
fmt.Sprintf("%s status", t.setupIssue.Title))
if !expect.Valid() {
return expect.ValidationFeedback return expect.ValidationFeedback
} }
taskpart1 := 0 for _, issue := range issues {
taskpart2 := 0 if issue.Title == t.priorityIssues[0].Title {
taskIssue := t.setupIssue expect.Equal(issue.Priority, 4, fmt.Sprintf("Priority of issue %s", issue.Title))
if taskIssue.Assignee != "Me" {
taskpart1++
}
expect.Assert(taskIssue.Assignee == "Me",
fmt.Sprintf("'%s' should be assigned to you", taskIssue.Title))
if taskIssue.Status == models.StatusOpen {
taskpart1++
}
if taskIssue.Status != models.StatusClosed {
expect.Assert(taskIssue.Status == models.StatusInProgress,
fmt.Sprintf("'%s' status should be 'In Progress'", taskIssue.Title))
}
if taskpart1>0 {
return expect.ValidationFeedback
}
for ii := range issues {
if issues[ii].Title == "Database connection failures" {
expect.Assert(issues[ii].Priority == 4,
fmt.Sprintf("'%s' priority should be 4 (critical)", issues[ii].Title))
if issues[ii].Priority != 4 {
taskpart2++
}
} else { } else {
expect.Assert(issues[ii].Priority == 1, expect.Equal(issue.Priority, 1, fmt.Sprintf("Priority of issue %s", issue.Title))
fmt.Sprintf("'%s' priority should be 1 (low)", issues[ii].Title))
if issues[ii].Priority != 1 {
taskpart2++
} }
} }
}
if taskpart2>0 {
return expect.ValidationFeedback
}
expect.Assert(taskIssue.Status == models.StatusClosed,
fmt.Sprintf("'%s' should be set to closed", taskIssue.Title))
return expect.Complete() return expect.Complete()
} }

View File

@@ -30,11 +30,21 @@ func NewExpector() *Expector {
} }
} }
func (e *Expector) Valid() bool {
return len(e.Errors()) == 0
}
func (e *Expector) Complete() ValidationFeedback { func (e *Expector) Complete() ValidationFeedback {
e.Success = len(e.Errors()) == 0 e.Success = len(e.Errors()) == 0
return e.ValidationFeedback return e.ValidationFeedback
} }
func (e *Expector) Fatal(message string) ValidationFeedback {
e.Success = false
e.Message = message
return e.ValidationFeedback
}
func (e *Expector) CompleteWithMessage(message string) ValidationFeedback { func (e *Expector) CompleteWithMessage(message string) ValidationFeedback {
e.Success = len(e.Errors()) == 0 e.Success = len(e.Errors()) == 0
if !e.Success { if !e.Success {