You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/06/18 09:24:23 UTC
[incubator-devlake] 05/10: update commit and pr review code
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit f1431a707a78e2e9c9ae007d75d0763edcfc4b1c
Author: Mr.An <42...@users.noreply.github.com>
AuthorDate: Fri Jun 17 11:55:39 2022 +0800
update commit and pr review code
---
plugins/gitee/models/migrationscripts/init_schema.go | 2 +-
plugins/gitee/tasks/commit_extractor.go | 2 --
plugins/gitee/tasks/pr_review_collector.go | 5 +++--
plugins/gitee/tasks/pr_review_extractor.go | 8 ++++----
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/plugins/gitee/models/migrationscripts/init_schema.go b/plugins/gitee/models/migrationscripts/init_schema.go
index 5eceb089..44e3e33a 100644
--- a/plugins/gitee/models/migrationscripts/init_schema.go
+++ b/plugins/gitee/models/migrationscripts/init_schema.go
@@ -46,7 +46,7 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
}
func (*InitSchemas) Version() uint64 {
- return 20220407201202
+ return 20220617201204
}
func (*InitSchemas) Name() string {
diff --git a/plugins/gitee/tasks/commit_extractor.go b/plugins/gitee/tasks/commit_extractor.go
index 3f280af5..1ebeb81e 100644
--- a/plugins/gitee/tasks/commit_extractor.go
+++ b/plugins/gitee/tasks/commit_extractor.go
@@ -48,7 +48,6 @@ type GiteeCommit struct {
type GiteeApiCommitResponse struct {
Author *models.GiteeUser `json:"author"`
- AuthorId int
CommentsUrl string `json:"comments_url"`
Commit GiteeCommit `json:"commit"`
Committer *models.GiteeUser `json:"committer"`
@@ -114,7 +113,6 @@ func ExtractApiCommits(taskCtx core.SubTaskContext) error {
func ConvertCommit(commit *GiteeApiCommitResponse) (*models.GiteeCommit, error) {
giteeCommit := &models.GiteeCommit{
Sha: commit.Sha,
- AuthorId: commit.Author.Id,
Message: commit.Commit.Message,
AuthorName: commit.Commit.Author.Name,
AuthorEmail: commit.Commit.Author.Email,
diff --git a/plugins/gitee/tasks/pr_review_collector.go b/plugins/gitee/tasks/pr_review_collector.go
index 0a64752e..468236f6 100644
--- a/plugins/gitee/tasks/pr_review_collector.go
+++ b/plugins/gitee/tasks/pr_review_collector.go
@@ -30,6 +30,7 @@ import (
"github.com/apache/incubator-devlake/plugins/gitee/models"
)
+//gitee
const RAW_PULL_REQUEST_REVIEW_TABLE = "gitee_api_pull_request_reviews"
var CollectApiPullRequestReviewsMeta = core.SubTaskMeta{
@@ -62,14 +63,14 @@ func CollectApiPullRequestReviews(taskCtx core.SubTaskContext) error {
Incremental: incremental,
Input: iterator,
- UrlTemplate: "repos/{{ .Params.Owner }}/{{ .Params.Repo }}/pulls/3/review",
+ UrlTemplate: "repos/{{ .Params.Owner }}/{{ .Params.Repo }}/pulls/{{ .Input.Number }}/operate_logs",
Query: func(reqData *helper.RequestData) (url.Values, error) {
query := url.Values{}
query.Set("access_token", data.Options.Token)
query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page))
query.Set("per_page", fmt.Sprintf("%v", reqData.Pager.Size))
-
+ query.Set("sort", "asc")
return query, nil
},
ResponseParser: func(res *http.Response) ([]json.RawMessage, error) {
diff --git a/plugins/gitee/tasks/pr_review_extractor.go b/plugins/gitee/tasks/pr_review_extractor.go
index fd4c0499..5fa79c38 100644
--- a/plugins/gitee/tasks/pr_review_extractor.go
+++ b/plugins/gitee/tasks/pr_review_extractor.go
@@ -38,10 +38,11 @@ type PullRequestReview struct {
User struct {
Id int
Login string
+ Name string
}
- Body string
- State string
- SubmittedAt helper.Iso8601Time `json:"submitted_at"`
+ Content string
+ ActionType string `json:"action_type"`
+ CreatedAt helper.Iso8601Time `json:"created_at"`
}
func ExtractApiPullRequestReviews(taskCtx core.SubTaskContext) error {
@@ -62,7 +63,6 @@ func ExtractApiPullRequestReviews(taskCtx core.SubTaskContext) error {
if err != nil {
return nil, err
}
- // need to extract 2 kinds of entities here
results := make([]interface{}, 0, 1)
giteeReviewer := &models.GiteeReviewer{