From f712ab1e27611ffe379e822cc8b320697fa92efe Mon Sep 17 00:00:00 2001 From: Nikita Bolotov <16142581+zyv4yk@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:58:17 +0300 Subject: [PATCH] fix(github_graphql): set the merged flag on pull requests The GraphQL extractor filled MergedAt, MergedBy and MergeCommit but never Merged, so every pull request collected through GraphQL is stored with merged = false, including the merged ones. #8573 fixed the same gap on the REST side; the GraphQL extractor was not part of it. The flag is derived from mergedAt, which GitHub sets exactly when a pull request is merged, so rows already sitting in the raw layer are repaired by re-running the extractor and no re-collect is needed. Co-Authored-By: Claude Opus 5 --- .../github_graphql/tasks/pr_extractor.go | 1 + .../github_graphql/tasks/pr_extractor_test.go | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 backend/plugins/github_graphql/tasks/pr_extractor_test.go diff --git a/backend/plugins/github_graphql/tasks/pr_extractor.go b/backend/plugins/github_graphql/tasks/pr_extractor.go index 59bc72cdb3f..51b41a9361b 100644 --- a/backend/plugins/github_graphql/tasks/pr_extractor.go +++ b/backend/plugins/github_graphql/tasks/pr_extractor.go @@ -171,6 +171,7 @@ func convertGithubPullRequest(pull *GraphqlQueryPr, connId uint64, repoId int) ( GithubUpdatedAt: pull.UpdatedAt, ClosedAt: pull.ClosedAt, MergedAt: pull.MergedAt, + Merged: pull.MergedAt != nil, // mergedAt is set exactly when a pull request is merged Body: pull.Body, BaseRef: pull.BaseRefName, BaseCommitSha: pull.BaseRefOid, diff --git a/backend/plugins/github_graphql/tasks/pr_extractor_test.go b/backend/plugins/github_graphql/tasks/pr_extractor_test.go new file mode 100644 index 00000000000..e5201eaebea --- /dev/null +++ b/backend/plugins/github_graphql/tasks/pr_extractor_test.go @@ -0,0 +1,56 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tasks + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestConvertGithubPullRequestMerged(t *testing.T) { + mergedAt := time.Date(2026, 8, 14, 10, 0, 0, 0, time.UTC) + + merged, err := convertGithubPullRequest(&GraphqlQueryPr{ + DatabaseId: 1, + Number: 1, + State: `MERGED`, + MergedAt: &mergedAt, + ClosedAt: &mergedAt, + }, 1, 1) + assert.Nil(t, err) + assert.True(t, merged.Merged) + + closed, err := convertGithubPullRequest(&GraphqlQueryPr{ + DatabaseId: 2, + Number: 2, + State: `CLOSED`, + ClosedAt: &mergedAt, + }, 1, 1) + assert.Nil(t, err) + assert.False(t, closed.Merged) + + open, err := convertGithubPullRequest(&GraphqlQueryPr{ + DatabaseId: 3, + Number: 3, + State: `OPEN`, + }, 1, 1) + assert.Nil(t, err) + assert.False(t, open.Merged) +}