Skip to content

[azuredevops_go] Implement Azure DevOps Boards (Work Items / TICKET domain) #2

@magiskboy

Description

@magiskboy

Bối cảnh

Plugin azuredevops_go hiện đã hỗ trợ Repository (code, PR) và Pipeline (CI/CD) ở mức ~95%. Phần Board (quản lý ticket / work items) chưa được implement — chỉ có stub đăng ký ticket.Board gắn nhầm vào repo domain ID trong api/blueprint_v200.go.

Mục tiêu: implement đầy đủ Boards theo pattern Jira plugin, để các dashboard chung (Engineering Overview, DORA, Throughput) và azure-dev-ops.json hoạt động với Azure DevOps giống Jira — không cần sửa SQL cross-dashboard.

Tham chiếu: backend/plugins/jira/, grafana/dashboards/mysql/Jira.json


Kiến trúc mục tiêu

Azure DevOps Cloud (WIQL, workitemsbatch, teams, iterations, updates)
        ↓
azuredevops_go (scope = AzuredevopsBoard / Team)
        ↓
_tool_azuredevops_go_*  →  Domain: boards, issues, board_issues, sprints, issue_changelogs, ...
        ↓
project_mapping (table=boards)  →  Grafana / DORA

Scope model: Board/Team độc lập với Git Repository (không gắn ticket.Board vào repo ID như stub hiện tại).

Domain ID: azuredevops_go:AzuredevopsBoard:{connectionId}:{teamId} (theo didgen).


Phạm vi implement

1. Models & migrations

  • models/board.goAzuredevopsBoard implements plugin.ToolLayerScope
  • models/work_item.go — tool-layer work item
  • models/board_work_item.go — junction board ↔ work item (tạo lúc extract, giống _tool_jira_board_issues)
  • models/iteration.go — iterations/sprints
  • Mở rộng models/scope_config.go:
    • TypeMappings (giống JiraScopeConfig)
    • StoryPointField (optional)
  • Migration scripts + đăng ký trong migrationscripts/register.go
  • Cập nhật GetTablesInfo() trong impl/impl.go

2. API client (api/azuredevops/client.go)

  • POST {org}/{project}/{team}/_apis/wit/wiql?api-version=7.1
  • POST {org}/_apis/wit/workitemsbatch (batch tối đa 200 IDs)
  • GET .../_apis/work/teams
  • GET .../teamsettings/iterations
  • GET .../iterations/{id}/workitems
  • GET .../wit/workitems/{id}/updates (changelog)
  • GET .../wit/workitems/{id}?$expand=relations (PR/commit links)

PAT scope: vso.work (read work items, boards, iterations)

3. Remote scopes & API

  • Remote scope groups: org/project
  • Remote scopes: Teams trong project (api/remote_helper.go)
  • Scope CRUD qua DsHelper (pattern Jira api/init.go, api/scope_api.go)
  • Cập nhật PrepareTaskData — task options {connectionId, boardId}

4. Subtasks (collect → extract → convert)

Mirror Jira pipeline:

Subtask Reference Jira
collect/extract/convert WorkItems (WIQL incremental qua [System.ChangedDate]) issue_collector.go, issue_extractor.go, issue_convertor.go
convertBoard board_convertor.go
collect/extract/convert Iterations sprint_collector.go, sprint_convertor.go
convertSprintIssues sprint_issues_convertor.go
collect/extract/convert WorkItemUpdates issue_changelog_*.go
collect/extract/convert WorkItemComments (optional) issue_comment_*.go
convertIssueCommits + convertIssueRepoCommits artifact links
convertPullRequestIssues (ADO native WI↔PR) mới — chưa có trong Jira

Domain tables bắt buộc:

  • boards, issues, board_issues
  • sprints, board_sprints, sprint_issues
  • issue_changelogs — normalize System.IterationPathfield_name = 'Sprint' (engineering-overview yêu cầu)
  • issue_commits, issue_repo_commits, pull_request_issues

Type/status mapping (scope config):

ADO Work Item Type issues.type
Bug BUG
User Story, PBI, Feature, Epic REQUIREMENT
Task TASK
Production Incident INCIDENT (cho DORA)
ADO State issues.status
New, To Do TODO
Active, In Progress IN_PROGRESS
Done, Closed, Resolved DONE

Fields bắt buộc: issue_key, title, type, status, priority, created_date, resolution_date, updated_date, lead_time_minutes, story_point, epic_key, creator_id, assignee_id

5. Blueprint (api/blueprint_v200.go)

  • Scope type Board riêng — pipeline plan độc lập với repo
  • Xóa stub ticket.NewBoard(repoId, ...) trên repo scope
  • Đăng ký domain scope ticket.Board khi entity TICKET bật
  • Subtasks filter theo DOMAIN_TYPE_TICKET

6. Config UI

  • AzureGoConfig.scopeConfig.entities — thêm TICKET
  • dataScope — hỗ trợ chọn Boards/Teams
  • Transformation UI — clone jira/transformation.tsx (typeMappings)
  • Cập nhật scope-config-form nếu cần

7. Grafana

  • mysql/azure-dev-ops.json — variable board_id: boards WHERE id LIKE 'azuredevops_go%'
  • Clone sections Issue Throughput + Issue Lead Time từ Jira.json
  • Cập nhật postgresql/azure-dev-ops.json

8. Tests & Docs

  • E2E: board_test.go, work_item_test.go
  • blueprint_v200_test.go — board scope pipeline
  • Cập nhật README.md — PAT scopes, Board setup, blueprint project_mapping

Incremental collection

SELECT [System.Id] FROM WorkItems
WHERE [System.TeamProject] = '{project}'
  AND [System.ChangedDate] >= '{last_sync_time}'
ORDER BY [System.ChangedDate] ASC

Giới hạn: WIQL max ~20K items/query; batch API max 200 items/request.


Acceptance Criteria

  • User chọn Team/Board scope, entity TICKET trong Config UI
  • Pipeline populate boards, issues, board_issues (prefix azuredevops_go:)
  • typeMappings chuẩn hóa type/status đúng enum DevLake
  • issue_changelogs.field_name = 'Sprint' cho Engineering Overview
  • type = INCIDENT → DORA tạo incidents (sau khi map board vào project)
  • azure-dev-ops.json hiển thị issue panels
  • E2E pass; không breaking repo/pipeline scopes hiện có

Ước lượng

~3–5 tuần

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions