Skip to content

Commit f712ab1

Browse files
zyv4ykclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 79ef9f4 commit f712ab1

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎backend/plugins/github_graphql/tasks/pr_extractor.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func convertGithubPullRequest(pull *GraphqlQueryPr, connId uint64, repoId int) (
171171
GithubUpdatedAt: pull.UpdatedAt,
172172
ClosedAt: pull.ClosedAt,
173173
MergedAt: pull.MergedAt,
174+
Merged: pull.MergedAt != nil, // mergedAt is set exactly when a pull request is merged
174175
Body: pull.Body,
175176
BaseRef: pull.BaseRefName,
176177
BaseCommitSha: pull.BaseRefOid,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package tasks
19+
20+
import (
21+
"testing"
22+
"time"
23+
24+
"github.com/stretchr/testify/assert"
25+
)
26+
27+
func TestConvertGithubPullRequestMerged(t *testing.T) {
28+
mergedAt := time.Date(2026, 8, 14, 10, 0, 0, 0, time.UTC)
29+
30+
merged, err := convertGithubPullRequest(&GraphqlQueryPr{
31+
DatabaseId: 1,
32+
Number: 1,
33+
State: `MERGED`,
34+
MergedAt: &mergedAt,
35+
ClosedAt: &mergedAt,
36+
}, 1, 1)
37+
assert.Nil(t, err)
38+
assert.True(t, merged.Merged)
39+
40+
closed, err := convertGithubPullRequest(&GraphqlQueryPr{
41+
DatabaseId: 2,
42+
Number: 2,
43+
State: `CLOSED`,
44+
ClosedAt: &mergedAt,
45+
}, 1, 1)
46+
assert.Nil(t, err)
47+
assert.False(t, closed.Merged)
48+
49+
open, err := convertGithubPullRequest(&GraphqlQueryPr{
50+
DatabaseId: 3,
51+
Number: 3,
52+
State: `OPEN`,
53+
}, 1, 1)
54+
assert.Nil(t, err)
55+
assert.False(t, open.Merged)
56+
}

0 commit comments

Comments
 (0)