mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(gitsync): enrich PR status with author, base branch, review info (#23038)
## Summary Adds 7 new fields to the PR status stored by gitsync, all sourced from the existing GitHub API calls (**zero additional HTTP requests**): | Field | Source | Purpose | |---|---|---| | `author_login` | `pull.user.login` | PR author username | | `author_avatar_url` | `pull.user.avatar_url` | PR author avatar for UI | | `base_branch` | `pull.base.ref` | Target branch (e.g. `main`) | | `pr_number` | `pull.number` | Explicit PR number | | `commits` | `pull.commits` | Number of commits in PR | | `approved` | Derived from reviews | True when ≥1 approved, no outstanding changes requested | | `reviewer_count` | Derived from reviews | Distinct reviewers with a decisive state | ## Changes - **`gitprovider/gitprovider.go`**: Added 7 fields to `PRStatus` struct. - **`gitprovider/github.go`**: Expanded the anonymous struct in `FetchPullRequestStatus` to decode new JSON fields. Replaced `hasOutstandingChangesRequested()` with `summarizeReviews()` returning a `reviewStats` struct with `changesRequested`, `approved`, and `reviewerCount`. - **Migration 000434**: Adds 7 columns to `chat_diff_statuses`. - **`queries/chats.sql`**: Updated `UpsertChatDiffStatus` INSERT/VALUES/ON CONFLICT. - **`gitsync/gitsync.go`**: Maps new `PRStatus` fields into upsert params. - **`gitsync/worker.go`**: Maps new columns in row-to-model converter. - **`codersdk/chats.go`**: Added fields to SDK `ChatDiffStatus` type. - **`coderd/chats.go`**: Maps new DB fields in `convertChatDiffStatus()`. - Auto-generated: `models.go`, `queries.sql.go`, `dump.sql`, `typesGenerated.ts`.
This commit is contained in:
@@ -364,6 +364,13 @@ INSERT INTO chat_diff_statuses (
|
||||
additions,
|
||||
deletions,
|
||||
changed_files,
|
||||
author_login,
|
||||
author_avatar_url,
|
||||
base_branch,
|
||||
pr_number,
|
||||
commits,
|
||||
approved,
|
||||
reviewer_count,
|
||||
refreshed_at,
|
||||
stale_at
|
||||
) VALUES (
|
||||
@@ -376,6 +383,13 @@ INSERT INTO chat_diff_statuses (
|
||||
@additions::integer,
|
||||
@deletions::integer,
|
||||
@changed_files::integer,
|
||||
sqlc.narg('author_login')::text,
|
||||
sqlc.narg('author_avatar_url')::text,
|
||||
sqlc.narg('base_branch')::text,
|
||||
sqlc.narg('pr_number')::integer,
|
||||
sqlc.narg('commits')::integer,
|
||||
sqlc.narg('approved')::boolean,
|
||||
sqlc.narg('reviewer_count')::integer,
|
||||
@refreshed_at::timestamptz,
|
||||
@stale_at::timestamptz
|
||||
)
|
||||
@@ -389,6 +403,13 @@ SET
|
||||
additions = EXCLUDED.additions,
|
||||
deletions = EXCLUDED.deletions,
|
||||
changed_files = EXCLUDED.changed_files,
|
||||
author_login = EXCLUDED.author_login,
|
||||
author_avatar_url = EXCLUDED.author_avatar_url,
|
||||
base_branch = EXCLUDED.base_branch,
|
||||
pr_number = EXCLUDED.pr_number,
|
||||
commits = EXCLUDED.commits,
|
||||
approved = EXCLUDED.approved,
|
||||
reviewer_count = EXCLUDED.reviewer_count,
|
||||
refreshed_at = EXCLUDED.refreshed_at,
|
||||
stale_at = EXCLUDED.stale_at,
|
||||
updated_at = NOW()
|
||||
|
||||
Reference in New Issue
Block a user