likyh opened a new pull request, #4320:
URL: https://github.com/apache/incubator-devlake/pull/4320
### Summary
add PageInOrder to support request pages one by one.
### Does this close any open issues?
Related to #4292
### Screenshots
add test code in collector:
```golang
collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
……
PageSize: 50,
PageInOrder: true,
Query: func(reqData *helper.RequestData) (url.Values,
errors.Error) {
query := url.Values{}
query.Set("state", "all")
query.Set("pagelen", fmt.Sprintf("%v",
reqData.Pager.Size))
if reqData.PrevPageResponse != nil {
resBody, err :=
io.ReadAll(reqData.PrevPageResponse.Body)
// decode json
u, err := url.Parse(rawMessages.Next)
query.Set("page", u.Query()[`page`][0])
}
return query, nil
},
})
```
```
time="2023-02-03 18:09:51" level=info msg=" [collectApiPullRequestCommits]
start api collection"
time="2023-02-03 18:09:52" level=info msg=" [collectApiPullRequestCommits]
finished records: 1"
# the first number means the page
# the second json means which pr is
# the third number means what the next page token is
1 {"BitbucketId":1} xGCox
1 {"BitbucketId":3}
1 {"BitbucketId":2} xGCox
2 {"BitbucketId":1} 7nSyG
2 {"BitbucketId":2} 7nSyG
3 {"BitbucketId":1} LRCkr
3 {"BitbucketId":2} LRCkr
4 {"BitbucketId":1} RaSbR
4 {"BitbucketId":2} RaSbR
time="2023-02-03 18:09:55" level=info msg=" [collectApiPullRequestCommits]
finished records: 10"
5 {"BitbucketId":1}
5 {"BitbucketId":2}
time="2023-02-03 18:09:56" level=info msg=" [collectApiPullRequestCommits]
end api collection without error"
time="2023-02-03 18:09:56" level=info msg="finished step: 5 / 5"
```
We can find 3 pr's commits are collected parallelly and each page in a PR
are collected in order.
--
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]