Open merge dialog instantly from pushed merge facts
This commit is contained in:
+18
-3
@@ -558,6 +558,10 @@ func (s *Store) queryTasks(ctx context.Context, query string, args ...any) ([]ap
|
||||
return tasks, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) ActiveTasks(ctx context.Context) ([]api.Task, error) {
|
||||
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE status = ? ORDER BY created_at`, string(api.TaskStatusActive))
|
||||
}
|
||||
|
||||
func (s *Store) ActiveSubtasks(ctx context.Context, parentID string) ([]api.Task, error) {
|
||||
return s.queryTasks(ctx, `SELECT `+taskColumns+` FROM tasks WHERE parent_task_id = ? AND status = ? ORDER BY created_at`, parentID, string(api.TaskStatusActive))
|
||||
}
|
||||
@@ -939,7 +943,11 @@ func closeRun(ctx context.Context, tx *sql.Tx, emit emitFunc, stageID, actor str
|
||||
}
|
||||
|
||||
func (s *Store) Participants(ctx context.Context, taskID string) ([]api.Participant, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `
|
||||
return participants(ctx, s.db, taskID)
|
||||
}
|
||||
|
||||
func participants(ctx context.Context, q querier, taskID string) ([]api.Participant, error) {
|
||||
rows, err := q.QueryContext(ctx, `
|
||||
SELECT u.login, u.display_name, u.git_name, u.git_email
|
||||
FROM events e JOIN users u ON u.login = e.actor
|
||||
WHERE e.task_id = ? AND (e.kind IN ('user.message', 'board.posted') OR (e.kind = 'task.created' AND json_extract(e.payload, '$.forked_from') IS NOT NULL))
|
||||
@@ -1702,7 +1710,7 @@ func (s *Store) ClearReviewRequests(ctx context.Context) error {
|
||||
|
||||
const projectColumns = `id, name, repo_path, default_branch, remote, created_by, created_at, review_workflow, audit_workflow`
|
||||
|
||||
const taskColumns = `id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, color, status, created_by, created_at, closed_at, merge_commit, todo_item, forked_from, forked_at, merge_queued_at, workflow_name, workflow_stage, parent_task_id, parent_merge_by, merge_after_review_by != '', state, merging_by != '' OR finalizing != '', discard_state != '' AND status = 'active', (SELECT coalesce(max(seq), 0) FROM events WHERE events.task_id = tasks.id AND kind = 'turn.ended' AND json_extract(payload, '$.summary') = 1), audit, ` + backgroundExpr
|
||||
const taskColumns = `id, project_id, title, merge_title, branch, worktree_path, base_ref, port_base, color, status, created_by, created_at, closed_at, merge_commit, todo_item, forked_from, forked_at, merge_queued_at, workflow_name, workflow_stage, parent_task_id, parent_merge_by, merge_after_review_by != '', state, merging_by != '' OR finalizing != '', discard_state != '' AND status = 'active', (SELECT coalesce(max(seq), 0) FROM events WHERE events.task_id = tasks.id AND kind = 'turn.ended' AND json_extract(payload, '$.summary') = 1), audit, ` + backgroundExpr + `, ` + mergeFactsColumns
|
||||
|
||||
// Keep the child lookup separate from the task itself so SQLite can use tasks_parent.
|
||||
const backgroundExpr = `(audit != '' OR EXISTS (SELECT 1 FROM tasks r WHERE r.id = tasks.parent_task_id AND tasks.workflow_stage != '' AND r.audit != ''))
|
||||
@@ -1742,7 +1750,14 @@ func scanTask(row scanner) (api.Task, error) {
|
||||
parentMergeBy := ""
|
||||
taskState := ""
|
||||
audit := ""
|
||||
err := row.Scan(&t.Id, &t.ProjectId, &t.Title, &t.MergeTitle, &t.Branch, &t.WorktreePath, &t.BaseRef, &t.PortBase, &t.Color, &status, &t.CreatedBy, &createdAt, &closedAt, &mergeCommit, &todoItem, &forkedFrom, &forkedAt, &mergeQueuedAt, &workflowName, &workflowStage, &parentTaskID, &parentMergeBy, &t.MergeAfterReview, &taskState, &t.Merging, &t.Discarding, &t.SummarySeq, &audit, &t.Background)
|
||||
participants := ""
|
||||
f := &t.MergeFacts
|
||||
err := row.Scan(&t.Id, &t.ProjectId, &t.Title, &t.MergeTitle, &t.Branch, &t.WorktreePath, &t.BaseRef, &t.PortBase, &t.Color, &status, &t.CreatedBy, &createdAt, &closedAt, &mergeCommit, &todoItem, &forkedFrom, &forkedAt, &mergeQueuedAt, &workflowName, &workflowStage, &parentTaskID, &parentMergeBy, &t.MergeAfterReview, &taskState, &t.Merging, &t.Discarding, &t.SummarySeq, &audit, &t.Background,
|
||||
&f.UnmergedCommits, &f.UnmergedFiles, &f.UnreviewedChanges, &f.ReviewSnapshot, &f.ReviewCount, &f.ReviewRunning, &f.ReviewFailed, &f.ReviewFindings, &participants)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
err = json.Unmarshal([]byte(participants), &f.Participants)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user