Skip to content

Commit 44f2db2

Browse files
authored
fix: Merged PRs incorrectly stored as closed with merged = false since March 2025
* fix(jira): update epic collector to use new API endpoint and include all fields * fix(jira): enhance epic collector to dynamically select API endpoint based on JIRA version * fix(jira): update epic collector to use correct API endpoint for JIRA Cloud and Server versions * fix(jira): refactor epic collector to streamline API endpoint selection and enhance error handling * fix(jira): fix type for Jira issue descriptions * refactor(jira): update comment and worklog models to use FlexibleDescription type for comments * docs(jira): add ADF reference for FlexibleDescription type in issue model * refactor(migrations): enhance file meta migration to check column existence and nullability before modification * fix(github): enhance pull request handling by including merged state and additional metrics itHub API pull request model. * Delete backend/plugins/q_dev/models/migrationscripts/20250320_modify_file_meta.go * recover
1 parent 7165b5b commit 44f2db2

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

backend/plugins/github/tasks/pr_collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func CollectApiPullRequests(taskCtx plugin.SubTaskContext) errors.Error {
110110
dal.Select("number"),
111111
dal.From(&models.GithubPullRequest{}),
112112
dal.Where(
113-
"repo_id = ? AND connection_id = ? AND state != 'closed'",
113+
"repo_id = ? AND connection_id = ? AND (state != 'closed' OR merged = false)",
114114
data.Options.GithubId, data.Options.ConnectionId,
115115
),
116116
)

backend/plugins/github/tasks/pr_convertor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func ConvertPullRequests(taskCtx plugin.SubTaskContext) errors.Error {
110110
}
111111
if pr.State == "open" || pr.State == "OPEN" {
112112
domainPr.Status = code.OPEN
113-
} else if (pr.State == "closed" && pr.MergedAt != nil) || pr.State == "MERGED" {
113+
} else if pr.State == "MERGED" || (pr.State == "closed" && (pr.Merged || pr.MergedAt != nil)) {
114114
domainPr.Status = code.MERGED
115115
} else {
116116
domainPr.Status = code.CLOSED

backend/plugins/github/tasks/pr_extractor.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ type GithubApiPullRequest struct {
6262
GithubCreatedAt common.Iso8601Time `json:"created_at"`
6363
GithubUpdatedAt common.Iso8601Time `json:"updated_at"`
6464
MergeCommitSha string `json:"merge_commit_sha"`
65+
Merged bool `json:"merged"`
66+
Additions int `json:"additions"`
67+
Deletions int `json:"deletions"`
68+
ChangedFiles int `json:"changed_files"`
69+
Comments int `json:"comments"`
70+
ReviewComments int `json:"review_comments"`
71+
Commits int `json:"commits"`
72+
IsDraft bool `json:"draft"`
73+
MergedBy *GithubAccountResponse `json:"merged_by"`
6574
Head struct {
6675
Ref string `json:"ref"`
6776
Sha string `json:"sha"`
@@ -182,10 +191,21 @@ func convertGithubPullRequest(pull *GithubApiPullRequest, connId uint64, repoId
182191
BaseCommitSha: pull.Base.Sha,
183192
HeadRef: pull.Head.Ref,
184193
HeadCommitSha: pull.Head.Sha,
194+
Merged: pull.Merged,
195+
Additions: pull.Additions,
196+
Deletions: pull.Deletions,
197+
Comments: pull.Comments,
198+
ReviewComments: pull.ReviewComments,
199+
Commits: pull.Commits,
200+
IsDraft: pull.IsDraft,
185201
}
186202
if pull.Head.Repo != nil {
187203
githubPull.HeadRepoId = pull.Head.Repo.GithubId
188204
}
205+
if pull.MergedBy != nil {
206+
githubPull.MergedByName = pull.MergedBy.Login
207+
githubPull.MergedById = pull.MergedBy.Id
208+
}
189209

190210
return githubPull, nil
191211
}

0 commit comments

Comments
 (0)