This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 44f2db27d fix: Merged PRs incorrectly stored as closed with merged = 
false since March 2025
44f2db27d is described below

commit 44f2db27d6cf441fb95cf24280f9cc056189a286
Author: Bamboo <[email protected]>
AuthorDate: Mon Sep 15 15:15:51 2025 +0800

    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
---
 backend/plugins/github/tasks/pr_collector.go |  2 +-
 backend/plugins/github/tasks/pr_convertor.go |  2 +-
 backend/plugins/github/tasks/pr_extractor.go | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/backend/plugins/github/tasks/pr_collector.go 
b/backend/plugins/github/tasks/pr_collector.go
index cc6d31e3a..45178b02e 100644
--- a/backend/plugins/github/tasks/pr_collector.go
+++ b/backend/plugins/github/tasks/pr_collector.go
@@ -110,7 +110,7 @@ func CollectApiPullRequests(taskCtx plugin.SubTaskContext) 
errors.Error {
                                        dal.Select("number"),
                                        dal.From(&models.GithubPullRequest{}),
                                        dal.Where(
-                                               "repo_id = ? AND connection_id 
= ? AND state != 'closed'",
+                                               "repo_id = ? AND connection_id 
= ? AND (state != 'closed' OR merged = false)",
                                                data.Options.GithubId, 
data.Options.ConnectionId,
                                        ),
                                )
diff --git a/backend/plugins/github/tasks/pr_convertor.go 
b/backend/plugins/github/tasks/pr_convertor.go
index eeb1caa5d..4a94d17df 100644
--- a/backend/plugins/github/tasks/pr_convertor.go
+++ b/backend/plugins/github/tasks/pr_convertor.go
@@ -110,7 +110,7 @@ func ConvertPullRequests(taskCtx plugin.SubTaskContext) 
errors.Error {
                        }
                        if pr.State == "open" || pr.State == "OPEN" {
                                domainPr.Status = code.OPEN
-                       } else if (pr.State == "closed" && pr.MergedAt != nil) 
|| pr.State == "MERGED" {
+                       } else if pr.State == "MERGED" || (pr.State == "closed" 
&& (pr.Merged || pr.MergedAt != nil)) {
                                domainPr.Status = code.MERGED
                        } else {
                                domainPr.Status = code.CLOSED
diff --git a/backend/plugins/github/tasks/pr_extractor.go 
b/backend/plugins/github/tasks/pr_extractor.go
index 6551dedbb..20f1bed01 100644
--- a/backend/plugins/github/tasks/pr_extractor.go
+++ b/backend/plugins/github/tasks/pr_extractor.go
@@ -62,6 +62,15 @@ type GithubApiPullRequest struct {
        GithubCreatedAt common.Iso8601Time     `json:"created_at"`
        GithubUpdatedAt common.Iso8601Time     `json:"updated_at"`
        MergeCommitSha  string                 `json:"merge_commit_sha"`
+       Merged          bool                   `json:"merged"`
+       Additions       int                    `json:"additions"`
+       Deletions       int                    `json:"deletions"`
+       ChangedFiles    int                    `json:"changed_files"`
+       Comments        int                    `json:"comments"`
+       ReviewComments  int                    `json:"review_comments"`
+       Commits         int                    `json:"commits"`
+       IsDraft         bool                   `json:"draft"`
+       MergedBy        *GithubAccountResponse `json:"merged_by"`
        Head            struct {
                Ref  string         `json:"ref"`
                Sha  string         `json:"sha"`
@@ -182,10 +191,21 @@ func convertGithubPullRequest(pull *GithubApiPullRequest, 
connId uint64, repoId
                BaseCommitSha:   pull.Base.Sha,
                HeadRef:         pull.Head.Ref,
                HeadCommitSha:   pull.Head.Sha,
+               Merged:          pull.Merged,
+               Additions:       pull.Additions,
+               Deletions:       pull.Deletions,
+               Comments:        pull.Comments,
+               ReviewComments:  pull.ReviewComments,
+               Commits:         pull.Commits,
+               IsDraft:         pull.IsDraft,
        }
        if pull.Head.Repo != nil {
                githubPull.HeadRepoId = pull.Head.Repo.GithubId
        }
+       if pull.MergedBy != nil {
+               githubPull.MergedByName = pull.MergedBy.Login
+               githubPull.MergedById = pull.MergedBy.Id
+       }
 
        return githubPull, nil
 }

Reply via email to