dosubot[bot] commented on issue #7969:
URL:
https://github.com/apache/incubator-devlake/issues/7969#issuecomment-2312882757
<!-- Greeting -->
Hello @peakwinter! I'm here to help you with any bugs, questions, or
contribution requests you have. I'll assist you while you wait for a human
maintainer.
<!-- Answer -->
To address the issue where the GitHub GraphQL collector fails on transferred
issues, you can modify the collector to ignore these issues and delete them
from the dataset. Here's how you can do it:
1. **Modify the `ResponseParser` function in the `CollectIssues` function**:
Add a check for the `StateReason` field in the `GraphqlQueryIssue`
struct. If the `StateReason` is "transferred", skip adding the issue to the
dataset.
```go
ResponseParser: func(queryWrapper any) (messages []json.RawMessage, err
errors.Error) {
query := queryWrapper.(*GraphqlQueryIssueWrapper)
issues := query.Repository.IssueList.Issues
for _, rawL := range issues {
if rawL.StateReason == "transferred" {
// Skip issues that have been transferred
continue
}
if since != nil && since.After(rawL.UpdatedAt) {
return messages, api.ErrFinishCollect
}
messages = append(messages, errors.Must1(json.Marshal(rawL)))
}
return
},
```
2. **Ensure the `StateReason` field is included in the GraphQL query**:
The `GraphqlQueryIssue` struct already includes the `StateReason` field,
so no changes are needed there.
```go
type GraphqlQueryIssue struct {
DatabaseId int
Number int
State string
StateReason string
Title string
Body string
Author *GraphqlInlineAccountQuery
Url string
ClosedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
AssigneeList struct {
Assignees []GraphqlInlineAccountQuery `graphql:"nodes"`
} `graphql:"assignees(first: 100)"`
Milestone *struct {
Number int
} `json:"milestone"`
Labels struct {
Nodes []struct {
Id string
Name string
}
} `graphql:"labels(first: 100)"`
}
```
With these changes, the collector will ignore issues that have been
transferred to another repository and will not include them in the dataset
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/github_graphql/tasks/issue_collector.go)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]