This is an automated email from the ASF dual-hosted git repository.
likyh 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 17af5970b fix(github): update incremental (#4044)
17af5970b is described below
commit 17af5970bf423d3b36476adbea39f4e204be0c7d
Author: Warren Chen <[email protected]>
AuthorDate: Wed Dec 28 11:35:09 2022 +0800
fix(github): update incremental (#4044)
---
plugins/github/tasks/cicd_run_collector.go | 12 +++++++-----
plugins/github/tasks/comment_collector.go | 5 +++++
plugins/github/tasks/pr_review_comment_collector.go | 5 +++++
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/plugins/github/tasks/cicd_run_collector.go
b/plugins/github/tasks/cicd_run_collector.go
index eea84e753..10c8127e8 100644
--- a/plugins/github/tasks/cicd_run_collector.go
+++ b/plugins/github/tasks/cicd_run_collector.go
@@ -60,13 +60,15 @@ func CollectRuns(taskCtx core.SubTaskContext) errors.Error {
UrlTemplate: "repos/{{ .Params.Name }}/actions/runs",
Query: func(reqData *helper.RequestData) (url.Values,
errors.Error) {
query := url.Values{}
- // data.CreatedDateAfter need to be used to filter
data, but now no params supported
- if incremental {
- startDate :=
collectorWithState.LatestState.LatestSuccessStart.Format("2006-01-02")
+ // if data.CreatedDateAfter != nil, we set since once
+ if data.CreatedDateAfter != nil {
+ startDate :=
data.CreatedDateAfter.Format("2006-01-02")
endDate := time.Now().Format("2006-01-02")
query.Set("created", fmt.Sprintf("%s..%s",
startDate, endDate))
- } else if data.CreatedDateAfter != nil {
- startDate :=
data.CreatedDateAfter.Format("2006-01-02")
+ }
+ // if incremental == true, we overwrite it
+ if incremental {
+ startDate :=
collectorWithState.LatestState.LatestSuccessStart.Format("2006-01-02")
endDate := time.Now().Format("2006-01-02")
query.Set("created", fmt.Sprintf("%s..%s",
startDate, endDate))
}
diff --git a/plugins/github/tasks/comment_collector.go
b/plugins/github/tasks/comment_collector.go
index d767a65f5..b295999a6 100644
--- a/plugins/github/tasks/comment_collector.go
+++ b/plugins/github/tasks/comment_collector.go
@@ -54,6 +54,11 @@ func CollectApiComments(taskCtx core.SubTaskContext)
errors.Error {
Query: func(reqData *helper.RequestData) (url.Values,
errors.Error) {
query := url.Values{}
query.Set("state", "all")
+ // if data.CreatedDateAfter != nil, we set since once
+ if data.CreatedDateAfter != nil {
+ query.Set("since",
data.CreatedDateAfter.String())
+ }
+ // if incremental == true, we overwrite it
if incremental {
query.Set("since",
collectorWithState.LatestState.LatestSuccessStart.String())
}
diff --git a/plugins/github/tasks/pr_review_comment_collector.go
b/plugins/github/tasks/pr_review_comment_collector.go
index e0e6bd0e8..7d9e1a6b6 100644
--- a/plugins/github/tasks/pr_review_comment_collector.go
+++ b/plugins/github/tasks/pr_review_comment_collector.go
@@ -56,6 +56,11 @@ func CollectPrReviewComments(taskCtx core.SubTaskContext)
errors.Error {
UrlTemplate: "repos/{{ .Params.Name }}/pulls/comments",
Query: func(reqData *helper.RequestData) (url.Values,
errors.Error) {
query := url.Values{}
+ // if data.CreatedDateAfter != nil, we set since once
+ if data.CreatedDateAfter != nil {
+ query.Set("since",
data.CreatedDateAfter.String())
+ }
+ // if incremental == true, we overwrite it
if incremental {
query.Set("since",
collectorWithState.LatestState.LatestSuccessStart.String())
}