You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/06/16 14:49:53 UTC

[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2224: Ref gitlab conn id mr note 2

likyh commented on code in PR #2224:
URL: https://github.com/apache/incubator-devlake/pull/2224#discussion_r899155957


##########
plugins/gitlab/e2e/mr_notes_test.go:
##########
@@ -0,0 +1,114 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package e2e
+
+import (
+	"fmt"
+	"github.com/apache/incubator-devlake/models/domainlayer/code"
+	"testing"
+
+	"github.com/apache/incubator-devlake/helpers/e2ehelper"
+	"github.com/apache/incubator-devlake/plugins/gitlab/impl"
+	"github.com/apache/incubator-devlake/plugins/gitlab/models"
+	"github.com/apache/incubator-devlake/plugins/gitlab/tasks"
+)
+
+func TestGitlabMrNoteDataFlow(t *testing.T) {
+
+	var gitlab impl.Gitlab
+	dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", gitlab)
+
+	taskData := &tasks.GitlabTaskData{
+		Options: &tasks.GitlabOptions{
+			ConnectionId: 1,
+			ProjectId:    20171709,
+		},
+	}
+
+	// import raw data table
+	dataflowTester.ImportCsvIntoRawTable("./tables/_raw_gitlab_api_merge_request_notes.csv",
+		"_raw_gitlab_api_merge_request_notes")
+
+	// verify extraction
+	dataflowTester.FlushTabler(&models.GitlabMergeRequestNote{})
+	dataflowTester.FlushTabler(&models.GitlabMergeRequestComment{})
+	dataflowTester.Subtask(tasks.ExtractApiMergeRequestsNotesMeta, taskData)

Review Comment:
   Can ExtractApiMergeRequestsNotesMeta run without GitlabMergeRequest?



##########
plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_merge_request_notes.csv:
##########
@@ -0,0 +1,146 @@
+connection_id,gitlab_id,merge_request_id,merge_request_iid,noteable_type,author_username,body,gitlab_created_at,confidential,resolvable,is_system,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+1,427956607,72934330,1,MergeRequest,gerilleto,"@lucas.rosa.merico sorry for the late response, i didn't notice this MR

Review Comment:
   It's cannot run in postgres. I suggest Good practice:
   ![origin_img_v2_b9e18ecf-6524-40e6-ad91-ddf8cf8ae68g](https://user-images.githubusercontent.com/3294100/174094697-0491fe1c-18c7-445d-8f07-e76afeb99554.jpg)
   ![origin_img_v2_c8635bba-fc98-4c4c-9684-4775038b5feg](https://user-images.githubusercontent.com/3294100/174094791-962aa455-fa59-43fe-a98a-1548d928c1ac.jpg)
   
   Bade practice:
   ![origin_img_v2_beb6b386-a612-463e-976e-1797b087426g](https://user-images.githubusercontent.com/3294100/174094845-e10a4cd9-8b2b-4261-80f7-1f83d7b1b0bd.jpg)
   
   it cannot run in pg because of the miss-match of "\r\n" and "\n". And I have no idea about this.



##########
plugins/gitlab/tasks/mr_note_extractor.go:
##########
@@ -73,11 +73,12 @@ func ExtractApiMergeRequestsNotes(taskCtx core.SubTaskContext) error {
 					AuthorUsername:  toolMrNote.AuthorUsername,
 					GitlabCreatedAt: toolMrNote.GitlabCreatedAt,
 					Resolvable:      toolMrNote.Resolvable,
+					ConnectionId:    data.Options.ConnectionId,
 				}
 				results = append(results, toolMrComment)
 
 			}
-
+			toolMrNote.ConnectionId = data.Options.ConnectionId

Review Comment:
   move to Line 65 after convertMergeRequestNote?



##########
plugins/gitlab/e2e/snapshot_tables/notes.csv:
##########
@@ -0,0 +1 @@
+id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,pr_id,type,author,body,resolvable,is_system,created_date

Review Comment:
   empty? Snapshot needs checking by human after creating auto.



##########
plugins/gitlab/impl/impl.go:
##########
@@ -68,13 +68,13 @@ func (plugin Gitlab) SubTaskMetas() []core.SubTaskMeta {
 		tasks.ExtractApiPipelinesMeta,
 		tasks.EnrichMergeRequestsMeta,
 		tasks.ConvertProjectMeta,
-		tasks.ConvertIssuesMeta,
-		tasks.ConvertIssueLabelsMeta,
 		tasks.ConvertApiMergeRequestsMeta,
-		tasks.ConvertApiCommitsMeta,
 		tasks.ConvertApiNotesMeta,
 		tasks.ConvertMergeRequestCommentMeta,
 		tasks.ConvertApiMergeRequestsCommitsMeta,
+		tasks.ConvertIssuesMeta,
+		tasks.ConvertIssueLabelsMeta,
+		tasks.ConvertApiCommitsMeta,

Review Comment:
   Is there any reason for the order?



##########
plugins/gitlab/e2e/snapshot_tables/pull_request_comments.csv:
##########
@@ -0,0 +1 @@
+id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,pull_request_id,body,user_id,created_date,commit_sha,position

Review Comment:
   empty?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org