Merge pull request #52 from LazyBachelor/LPM-84-fixed

LPM-84 Priority Management Task
This commit is contained in:
Robin Olsen
2026-03-11 12:40:37 -07:00
committed by GitHub
2 changed files with 53 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ package tasks
import ( import (
"context" "context"
"fmt"
"github.com/LazyBachelor/LazyPM/internal/models" "github.com/LazyBachelor/LazyPM/internal/models"
"github.com/LazyBachelor/LazyPM/internal/utils/check" "github.com/LazyBachelor/LazyPM/internal/utils/check"
@@ -10,21 +11,22 @@ import (
const priorityManagementDescription = `You are tasked with managing issue priorities. const priorityManagementDescription = `You are tasked with managing issue priorities.
A critical production issue has been reported. You need to rebalance the current sprint priorities: A critical production issue has been reported.
1. Review all current issues and their priorities The database is not working properly and users are not able to connect and access their data.
2. Identify the most urgent production issue
3. Reprioritize existing work to accommodate the urgent fix
4. Defer lower priority items if necessary
5. Update the team on priority changes via comments
6. Ensure the critical path is clear for the urgent fix
The production database is experiencing intermittent connection failures affecting all users.` 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".
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).`
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 {
@@ -63,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.").
@@ -74,34 +76,34 @@ func (t *PriorityManagementTask) Setup(ctx context.Context) error {
NewIssueBuilder(). NewIssueBuilder().
WithTitle("UI theme updates"). WithTitle("UI theme updates").
WithDescription("Update color scheme per new brand guidelines. Currently in progress but can wait."). WithDescription("Update color scheme per new brand guidelines. Currently in progress but can wait.").
WithPriority(1). WithPriority(2).
WithStatus(models.StatusInProgress). WithStatus(models.StatusInProgress).
WithIssueType(models.TypeTask). WithIssueType(models.TypeFeature).
Build(), Build(),
NewIssueBuilder(). NewIssueBuilder().
WithTitle("Feature: Dark mode"). WithTitle("Feature: Dark mode").
WithDescription("Add dark mode toggle to settings. Nice to have, can be deferred."). WithDescription("Add dark mode toggle to settings. Nice to have, can be deferred.").
WithPriority(2). WithPriority(2).
WithStatus(models.StatusOpen). WithStatus(models.StatusOpen).
WithIssueType(models.TypeTask). WithIssueType(models.TypeFeature).
Build(), Build(),
NewIssueBuilder(). NewIssueBuilder().
WithTitle("API rate limiting"). WithTitle("API rate limiting").
WithDescription("Add rate limiting to public API endpoints. Security enhancement."). WithDescription("Add rate limiting to public API endpoints. Security enhancement.").
WithPriority(2). WithPriority(2).
WithStatus(models.StatusInProgress). WithStatus(models.StatusInProgress).
WithIssueType(models.TypeTask). WithIssueType(models.TypeFeature).
Build(), Build(),
NewIssueBuilder(). NewIssueBuilder().
WithTitle("Documentation updates"). WithTitle("Documentation updates").
WithDescription("Update API documentation for v2 endpoints. Can be deferred."). WithDescription("Update API documentation for v2 endpoints. Can be deferred.").
WithPriority(3). WithPriority(3).
WithStatus(models.StatusOpen). WithStatus(models.StatusOpen).
WithIssueType(models.TypeTask). WithIssueType(models.TypeChore).
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
} }
@@ -116,5 +118,28 @@ func (t *PriorityManagementTask) Setup(ctx context.Context) error {
func (t *PriorityManagementTask) Validate(ctx context.Context) ValidationFeedback { func (t *PriorityManagementTask) Validate(ctx context.Context) ValidationFeedback {
expect := check.NewExpector() expect := check.NewExpector()
issues, err := FetchIssues(ctx, t.app, t.setupIssue)
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
}
for _, issue := range issues {
if issue.Title == t.priorityIssues[0].Title {
expect.Equal(issue.Priority, 4, fmt.Sprintf("Priority of issue %s", issue.Title))
} else {
expect.Equal(issue.Priority, 1, fmt.Sprintf("Priority of issue %s", issue.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 {