Skip closed task history in lead and TODO queries
This commit is contained in:
@@ -881,14 +881,14 @@ func (m *Manager) listTasksText(ctx context.Context) (string, error) {
|
|||||||
b := &strings.Builder{}
|
b := &strings.Builder{}
|
||||||
for _, p := range projects {
|
for _, p := range projects {
|
||||||
fmt.Fprintf(b, "## %s (project %s, repo %s, default branch %s)\n", p.Name, p.Id, p.RepoPath, p.DefaultBranch)
|
fmt.Fprintf(b, "## %s (project %s, repo %s, default branch %s)\n", p.Name, p.Id, p.RepoPath, p.DefaultBranch)
|
||||||
tasks, err := m.store.ListTasks(ctx, p.Id)
|
tasks, err := m.store.ListActiveTasks(ctx, p.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
listed := false
|
listed := false
|
||||||
started := map[string]bool{}
|
started := map[string]bool{}
|
||||||
for _, t := range tasks {
|
for _, t := range tasks {
|
||||||
if t.Status != api.TaskStatusActive || t.Background {
|
if t.Background {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
listed = true
|
listed = true
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ func (m *Manager) StartTodo(ctx context.Context, project api.Project, creator ap
|
|||||||
return nil, fmt.Errorf("%w: %s on %s has no item %q", store.ErrNotFound, todo.File, project.DefaultBranch, title)
|
return nil, fmt.Errorf("%w: %s on %s has no item %q", store.ErrNotFound, todo.File, project.DefaultBranch, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := m.store.ListTasks(ctx, project.Id)
|
tasks, err := m.store.ListActiveTasks(ctx, project.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, t := range tasks {
|
for _, t := range tasks {
|
||||||
if t.Status == api.TaskStatusActive && t.TodoItem != nil && *t.TodoItem == title {
|
if t.TodoItem != nil && *t.TodoItem == title {
|
||||||
return nil, fmt.Errorf("%w: task %s is already working on %q", ErrConflict, t.Id, title)
|
return nil, fmt.Errorf("%w: task %s is already working on %q", ErrConflict, t.Id, title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,10 +407,6 @@ func (s *Store) CreateTask(ctx context.Context, t api.Task, frozen *FrozenWorkfl
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) ListTasks(ctx context.Context, projectID string) ([]api.Task, error) {
|
|
||||||
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE project_id = ? ORDER BY created_at DESC`, projectID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Store) ListActiveTasks(ctx context.Context, projectID string) ([]api.Task, error) {
|
func (s *Store) ListActiveTasks(ctx context.Context, projectID string) ([]api.Task, error) {
|
||||||
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE project_id = ? AND status = ? ORDER BY created_at DESC`, projectID, string(api.TaskStatusActive))
|
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE project_id = ? AND status = ? ORDER BY created_at DESC`, projectID, string(api.TaskStatusActive))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user