Files
LazyPM/internal/models/app.go
Robin Olsen d900a5fcd3 Merge pull request #75 from LazyBachelor/LPM-140
LPM-140 The Sprinting Update
Adds sprint support across the web UI (board + issue detail), TUI kanban, CLI/REPL, and the Beads-backed storage layer.

Changes:

Introduces sprint entities in storage and exposes sprint operations via IssueService.
Updates web board to support backlog vs. sprint columns, sprint selection, and sprint creation routes.
Updates TUI kanban to show backlog + sprint columns and adds sprint selection/creation actions.
2026-03-23 19:26:04 +01:00

75 lines
2.3 KiB
Go

package models
import (
"context"
"log/slog"
"go.mongodb.org/mongo-driver/v2/bson"
)
type App struct {
Config Config
Issues IssueService
Stats StatsService
Logger *slog.Logger
Tasks map[string]Tasker
Interfaces map[string]Interface
CurrentFeedback *ValidationFeedback
ActionLogger func(string)
SubmitChan chan<- struct{}
}
func (a *App) LogAction(action string) {
if a == nil || action == "" {
return
}
if a.Logger != nil {
a.Logger.Info("action event", "action", action)
}
if a.ActionLogger != nil {
a.ActionLogger(action)
}
}
// IssueService defines the interface for managing issues in the application.
// This a siplification of the Beads issue storage interface, tailored to our needs.
type IssueService interface {
CreateIssue(ctx context.Context, issue *Issue, actor string) error
CreateIssues(ctx context.Context, issues []*Issue, actor string) error
UpdateIssue(ctx context.Context, id string, updates map[string]any, actor string) error
CloseIssue(ctx context.Context, id string, reason string, actor string, session string) error
DeleteIssue(ctx context.Context, id string) error
DeleteIssues() error
GetIssue(ctx context.Context, id string) (*Issue, error)
SearchIssues(ctx context.Context, query string, filter IssueFilter) ([]*Issue, error)
AddIssueComment(ctx context.Context, issueID, author, text string) (*Comment, error)
GetIssueComments(ctx context.Context, issueID string) ([]*Comment, error)
GetCommentCounts(ctx context.Context, issueIDs []string) (map[string]int, error)
AddSprint(ctx context.Context) (int, error)
RemoveSprint(ctx context.Context, sprintNum int) error
GetSprints(ctx context.Context) ([]int, error)
GetBacklogSprint(ctx context.Context) (int, error)
GetIssuesBySprint(ctx context.Context, sprintNum int) ([]*Issue, error)
GetIssuesNotInAnySprint(ctx context.Context) ([]*Issue, error)
AddIssueToSprint(ctx context.Context, issueID string, sprintNum int) error
RemoveIssueFromSprint(ctx context.Context, issueID string, sprintNum int) error
}
type StatsService interface {
Load(ctx context.Context) error
Save(ctx context.Context) error
GetStatistics() (Statistics, error)
GetParticipantID() bson.ObjectID
RecordTaskRun(ctx context.Context, run TaskRunMetrics) error
RecordIntroQuestionnaireAnswers(answers map[string]any) error
}