This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 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 cf50c882 refactor(gitlab): add conn id to mr (#2220)
cf50c882 is described below

commit cf50c88238b96212a2f613590e33171b5dc881af
Author: Warren Chen <[email protected]>
AuthorDate: Thu Jun 16 22:12:04 2022 +0800

    refactor(gitlab): add conn id to mr (#2220)
---
 plugins/gitlab/e2e/{project_test.go => mr_test.go} | 85 ++++++++++++++--------
 plugins/gitlab/e2e/project_test.go                 |  5 +-
 .../_tool_gitlab_merge_requests.csv                | 28 +++++++
 .../_tool_gitlab_projects.csv                      |  0
 .../gitlab/e2e/snapshot_tables/pull_requests.csv   | 28 +++++++
 .../e2e/{tables => snapshot_tables}/repos.csv      |  0
 .../e2e/tables/_raw_gitlab_api_merge_requests.csv  | 28 +++++++
 plugins/gitlab/tasks/issue_collector.go            |  2 +-
 plugins/gitlab/tasks/mr_convertor.go               |  8 +-
 plugins/gitlab/tasks/mr_enricher.go                |  8 +-
 plugins/gitlab/tasks/mr_extractor.go               |  3 +-
 11 files changed, 152 insertions(+), 43 deletions(-)

diff --git a/plugins/gitlab/e2e/project_test.go b/plugins/gitlab/e2e/mr_test.go
similarity index 58%
copy from plugins/gitlab/e2e/project_test.go
copy to plugins/gitlab/e2e/mr_test.go
index 6c094b46..25699b49 100644
--- a/plugins/gitlab/e2e/project_test.go
+++ b/plugins/gitlab/e2e/mr_test.go
@@ -18,16 +18,17 @@ 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/models/domainlayer/code"
        "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 TestGitlabProjectDataFlow(t *testing.T) {
+func TestGitlabMrDataFlow(t *testing.T) {
 
        var gitlab impl.Gitlab
        dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", gitlab)
@@ -35,35 +36,44 @@ func TestGitlabProjectDataFlow(t *testing.T) {
        taskData := &tasks.GitlabTaskData{
                Options: &tasks.GitlabOptions{
                        ConnectionId: 1,
-                       ProjectId:    3472737,
+                       ProjectId:    18524154,
                },
        }
 
        // import raw data table
-       
dataflowTester.ImportCsvIntoRawTable("./tables/_raw_gitlab_api_projects.csv",
-               "_raw_gitlab_api_project")
+       
dataflowTester.ImportCsvIntoRawTable("./tables/_raw_gitlab_api_merge_requests.csv",
+               "_raw_gitlab_api_merge_requests")
 
        // verify extraction
-       dataflowTester.FlushTabler(&models.GitlabProject{})
-       dataflowTester.Subtask(tasks.ExtractProjectMeta, taskData)
+       dataflowTester.FlushTabler(&models.GitlabMergeRequest{})
+       dataflowTester.Subtask(tasks.ExtractApiMergeRequestsMeta, taskData)
        dataflowTester.VerifyTable(
-               models.GitlabProject{},
-               "tables/_tool_gitlab_projects.csv",
+               models.GitlabMergeRequest{},
+               fmt.Sprintf("./snapshot_tables/%s.csv", 
models.GitlabMergeRequest{}.TableName()),
                []string{"connection_id", "gitlab_id"},
                []string{
-                       "name",
-                       "description",
-                       "default_branch",
-                       "path_with_namespace",
+                       "iid",
+                       "project_id",
+                       "source_project_id",
+                       "target_project_id",
+                       "state",
+                       "title",
                        "web_url",
-                       "creator_id",
-                       "visibility",
-                       "open_issues_count",
-                       "star_count",
-                       "forked_from_project_id",
-                       "forked_from_project_web_url",
-                       "created_date",
-                       "updated_date",
+                       "user_notes_count",
+                       "work_in_progress",
+                       "source_branch",
+                       "target_branch",
+                       "merge_commit_sha",
+                       "merged_at",
+                       "gitlab_created_at",
+                       "closed_at",
+                       "merged_by_username",
+                       "description",
+                       "author_username",
+                       "author_user_id",
+                       "component",
+                       "first_comment_time",
+                       "review_rounds",
                        "_raw_data_params",
                        "_raw_data_table",
                        "_raw_data_id",
@@ -72,26 +82,37 @@ func TestGitlabProjectDataFlow(t *testing.T) {
        )
 
        // verify conversion
-       dataflowTester.FlushTabler(&code.Repo{})
-       dataflowTester.Subtask(tasks.ConvertProjectMeta, taskData)
+       dataflowTester.FlushTabler(&code.PullRequest{})
+       dataflowTester.Subtask(tasks.ConvertApiMergeRequestsMeta, taskData)
        dataflowTester.VerifyTable(
-               code.Repo{},
-               "tables/repos.csv",
+               code.PullRequest{},
+               fmt.Sprintf("./snapshot_tables/%s.csv", 
code.PullRequest{}.TableName()),
                []string{"id"},
                []string{
                        "_raw_data_params",
                        "_raw_data_table",
                        "_raw_data_id",
                        "_raw_data_remark",
-                       "name",
-                       "url",
+                       "base_repo_id",
+                       "head_repo_id",
+                       "status",
+                       "title",
                        "description",
-                       "owner_id",
-                       "language",
-                       "forked_from",
+                       "url",
+                       "author_name",
+                       "author_id",
+                       "parent_pr_id",
+                       "pull_request_key",
                        "created_date",
-                       "updated_date",
-                       "deleted",
+                       "merged_date",
+                       "closed_date",
+                       "type",
+                       "component",
+                       "merge_commit_sha",
+                       "head_ref",
+                       "base_ref",
+                       "base_commit_sha",
+                       "head_commit_sha",
                },
        )
 }
diff --git a/plugins/gitlab/e2e/project_test.go 
b/plugins/gitlab/e2e/project_test.go
index 6c094b46..dbe276d7 100644
--- a/plugins/gitlab/e2e/project_test.go
+++ b/plugins/gitlab/e2e/project_test.go
@@ -18,6 +18,7 @@ limitations under the License.
 package e2e
 
 import (
+       "fmt"
        "testing"
 
        "github.com/apache/incubator-devlake/helpers/e2ehelper"
@@ -48,7 +49,7 @@ func TestGitlabProjectDataFlow(t *testing.T) {
        dataflowTester.Subtask(tasks.ExtractProjectMeta, taskData)
        dataflowTester.VerifyTable(
                models.GitlabProject{},
-               "tables/_tool_gitlab_projects.csv",
+               fmt.Sprintf("./snapshot_tables/%s.csv", 
models.GitlabProject{}.TableName()),
                []string{"connection_id", "gitlab_id"},
                []string{
                        "name",
@@ -76,7 +77,7 @@ func TestGitlabProjectDataFlow(t *testing.T) {
        dataflowTester.Subtask(tasks.ConvertProjectMeta, taskData)
        dataflowTester.VerifyTable(
                code.Repo{},
-               "tables/repos.csv",
+               fmt.Sprintf("./snapshot_tables/%s.csv", 
code.Repo{}.TableName()),
                []string{"id"},
                []string{
                        "_raw_data_params",
diff --git a/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_merge_requests.csv 
b/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_merge_requests.csv
new file mode 100644
index 00000000..9894bd14
--- /dev/null
+++ b/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_merge_requests.csv
@@ -0,0 +1,28 @@
+connection_id,gitlab_id,iid,project_id,source_project_id,target_project_id,state,title,web_url,user_notes_count,work_in_progress,source_branch,target_branch,merge_commit_sha,merged_at,gitlab_created_at,closed_at,merged_by_username,description,author_username,author_user_id,component,first_comment_time,review_rounds,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+1,69981719,1,18524154,18524154,18524154,merged,Add report_object_name to 
AnalysisMessage,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/1,0,0,notify-report-url,master,d64d19e1c6f3c80118f89bc34583416efe5dcfc1,2020-09-06T11:20:53.522+00:00,2020-09-06T11:20:15.288+00:00,,liangjingyang,,liangjingyang,1678508,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,1,
+1,71846142,2,18524154,18524154,18524154,merged,Add force_analyze parameter to 
SubmitRepoRequest,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/2,0,0,force-analyze,master,921791c4f2f26304c7e51eabad1266ef584ffc0e,2020-09-23T11:16:40.584+00:00,2020-09-23T11:16:22.000+00:00,,liangjingyang,,liangjingyang,1678508,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,2,
+1,76106237,3,18524154,18524154,18524154,closed,Add commit author info in 
protobuf,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/3,0,0,commit_author,master,,,2020-10-29T09:57:18.574+00:00,2020-11-16T07:07:36.578+00:00,,,huiqingu,6495855,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,3,
+1,76836841,4,18524154,18524154,18524154,merged,Add original commit author 
info,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/4,0,0,sqaushed_merge_commit_author,master,2fce14f9a106764d34a07c28c037623311a76b5e,2020-11-05T08:16:11.481+00:00,2020-11-04T13:58:02.637+00:00,,liangjingyang,,huiqingu,6495855,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,4,
+1,79206897,5,18524154,18524154,18524154,merged,Add 
ContributorBombSweep,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/5,0,0,bomb_sweep,master,dfcd0eb642440ccdafcdd37ed50430514284b420,2020-11-24T02:46:34.983+00:00,2020-11-24T00:18:11.350+00:00,,liangjingyang,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,5,
+1,79236629,6,18524154,18524154,18524154,merged,Fix 
syntax,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/6,0,0,fix_syntax,master,940d7bc03873ef9bfd92d6131e31bc7f05746247,2020-11-24T03:00:00.688+00:00,2020-11-24T02:59:39.585+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,6,
+1,79742054,7,18524154,18524154,18524154,merged,Add test of time 
badge,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/7,1,0,test_of_time,master,39ca820d779433cdf737d503ecab768d844f5de3,2020-12-01T08:48:40.595+00:00,2020-11-27T08:17:41.396+00:00,,huiqingu,,huiqingu,6495855,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,7,
+1,80123152,8,18524154,18524154,18524154,merged,Change rank type and rename 
developer_test_of_time,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/8,0,0,change_rank_type,master,a7a56a4098094bc4ca2a4a34fb9b0a7940f62756,2020-12-01T09:09:34.668+00:00,2020-12-01T08:58:57.094+00:00,,huiqingu,,huiqingu,6495855,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,8,
+1,81364800,9,18524154,18524154,18524154,merged,Add 
package_to_tags,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/9,0,0,package_to_tag,master,4aca49223d4f978c63284ca44e45e4fcaaa682f9,2020-12-11T06:07:40.831+00:00,2020-12-11T06:07:13.107+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,9,
+1,81371049,10,18524154,18524154,18524154,merged,Change tag_ids to 
tag_names,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/10,0,0,package_to_tag,master,0f8d2f61e30d7b47e37966f4f706aa95d9413ae1,2020-12-11T06:57:24.855+00:00,2020-12-11T06:57:16.282+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,10,
+1,81379647,11,18524154,18524154,18524154,merged,Finally use 
tag_ids,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/11,0,0,package_to_tag_id,master,e93f7370d63b5c7b80aa53a9b8973d3a3b646f67,2020-12-11T08:40:33.244+00:00,2020-12-11T08:40:17.471+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,11,
+1,83243616,12,18524154,18524154,18524154,merged,Add tag for 
report,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/12,0,0,add_tag,master,378144b4fabf925d3ff97de287affbac39197902,2020-12-30T06:51:58.005+00:00,2020-12-30T06:46:52.904+00:00,,liangjingyang,,huiqingu,6495855,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,12,
+1,84599747,13,18524154,18524154,18524154,merged,Add cpu. memory and 
timestamps,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/13,0,0,add_cpu_mem_time,master,ecea0b568577f76a83273f081fdb05d9a0cd6dce,2021-01-13T14:21:45.564+00:00,2021-01-13T14:13:04.376+00:00,,liangjingyang,,ghost1,1243277,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,13,
+1,84609384,14,18524154,18524154,18524154,merged,add semi 
colons,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/14,0,0,add_cpu_mem_time_fix,master,7a2a331658f453e650d836e400b767a9c881fbeb,2021-01-13T15:17:05.858+00:00,2021-01-13T15:16:54.520+00:00,,,,ghost1,1243277,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,14,
+1,93412412,15,18524154,18524154,18524154,merged,Refactor repeated fields in 
report_of_all to 
streaming,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/15,0,0,refactor-repeated-to-streaming,master,727871ad985bc001b82a0b5bf0d11415a12127cb,2021-04-01T06:52:40.834+00:00,2021-03-25T07:31:36.715+00:00,,liangjingyang,,liangjingyang,1678508,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,15,
+1,94277896,16,18524154,18524154,18524154,merged,Add churned equivalent 
proto,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/16,0,0,churned-equivalent,master,2586046536fbdae442e8dd295573bc6bf3a1e2e4,2021-04-01T07:08:19.183+00:00,2021-04-01T06:46:34.175+00:00,,luosw,,luosw,3406788,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,16,
+1,96157995,17,18524154,18524154,18524154,merged,Add combined list to 
SubmitRepoRequest,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/17,0,0,combined-analysis,master,20d7d68963114fda55eb89bc73bd427aac0a22b0,2021-04-26T08:46:17.510+00:00,2021-04-16T02:43:12.214+00:00,,liangjingyang,,liangjingyang,1678508,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,17,
+1,96784148,18,18524154,18524154,18524154,merged,Remove original churned deveq 
& add churned deveq to 
aggregation,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/18,0,0,churned-equivalent,master,191c9309d3579498fbf3e76a4b18b7eb15aee24f,2021-04-21T10:12:17.362+00:00,2021-04-21T10:11:47.819+00:00,,luosw,,luosw,3406788,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,18,
+1,96794553,19,18524154,18524154,18524154,merged,Remove origin churned 
deveq,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/19,0,0,churned-equivalent,master,944383b28553ad916f7b46422688e765e803200e,2021-04-21T11:31:13.194+00:00,2021-04-21T11:30:55.426+00:00,,luosw,,luosw,3406788,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,19,
+1,114440893,20,18524154,18524154,18524154,closed,Draft: Techtag 
proto,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/20,0,1,techtag-proto,master,,,2021-08-30T02:00:21.174+00:00,2021-09-08T05:59:00.024+00:00,,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,20,
+1,115501302,21,18524154,18524154,18524154,merged,Add language feature 
proto,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/21,0,0,lang_feat_proto,master,5b51780aef5033563f06798126b01c15faaee785,2021-09-05T10:36:59.393+00:00,2021-09-05T10:36:51.256+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,21,
+1,115676082,22,18524154,18524154,18524154,merged,Update tech tag 
proto,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/22,1,0,update_techtag_proto,master,9f618daee0b4c4a2e3f2ec441cedcf281364c575,2021-09-07T12:05:10.826+00:00,2021-09-07T00:43:21.835+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,22,
+1,118474761,23,18524154,18524154,18524154,opened,Mark contributor_bomb_sweep & 
test_of_time_functions as 
deprecated,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/23,0,0,deprecate_ce_badge_metric,master,,,2021-09-27T06:37:08.002+00:00,,,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,23,
+1,120408790,24,18524154,18524154,18524154,merged,Add some fields to CaAnalysis 
and 
CaTask,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/24,0,0,add-started-at-and-completed-at,master,0401d004a0d0aaf3885e6051fc22e1fca44dcee1,2021-10-08T06:12:21.672+00:00,2021-10-08T06:12:06.684+00:00,,liangjingyang,,liangjingyang,1678508,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,24,
+1,122908069,25,18524154,18524154,18524154,merged,Add details for 
debug,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/25,0,0,debug_details,master,a2646bb96b70058c11ca1db6dfd200dc8a24a9d3,2021-10-26T01:12:37.943+00:00,2021-10-26T00:43:54.694+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,25,
+1,123028722,26,18524154,18524154,18524154,merged,Add debug mode in request 
parameter,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/26,0,0,debug_mode,master,125548e3739b84835662b751c3b72f6b13c74591,2021-10-26T14:08:36.297+00:00,2021-10-26T14:08:14.439+00:00,,kagami_,,kagami_,3412597,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,26,
+1,134847762,27,18524154,18524154,18524154,closed,add aspect ast node 
count,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/27,0,0,add-aspect-ast-node-count,master,,,2022-01-12T16:18:18.192+00:00,2022-01-13T13:06:18.100+00:00,,,ShiwenLuo,9183827,,,0,2022-06-16T08:33:44.415+00:00,2022-06-16T08:33:44.415+00:00,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,27,
diff --git a/plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv 
b/plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_projects.csv
similarity index 100%
rename from plugins/gitlab/e2e/tables/_tool_gitlab_projects.csv
rename to plugins/gitlab/e2e/snapshot_tables/_tool_gitlab_projects.csv
diff --git a/plugins/gitlab/e2e/snapshot_tables/pull_requests.csv 
b/plugins/gitlab/e2e/snapshot_tables/pull_requests.csv
new file mode 100644
index 00000000..cdcf03aa
--- /dev/null
+++ b/plugins/gitlab/e2e/snapshot_tables/pull_requests.csv
@@ -0,0 +1,28 @@
+id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,base_repo_id,head_repo_id,status,title,description,url,author_name,author_id,parent_pr_id,pull_request_key,created_date,merged_date,closed_date,type,component,merge_commit_sha,head_ref,base_ref,base_commit_sha,head_commit_sha
+gitlab:GitlabMergeRequest:1:114440893,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,20,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,closed,Draft:
 Techtag 
proto,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/20,kagami_,,,20,2021-08-30T02:00:21.174+00:00,,2021-09-08T05:59:00.024+00:00,,,,techtag-proto,master,,
+gitlab:GitlabMergeRequest:1:115501302,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,21,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 language feature 
proto,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/21,kagami_,,,21,2021-09-05T10:36:51.256+00:00,2021-09-05T10:36:59.393+00:00,,,,5b51780aef5033563f06798126b01c15faaee785,lang_feat_proto,master,,
+gitlab:GitlabMergeRequest:1:115676082,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,22,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Update
 tech tag 
proto,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/22,kagami_,,,22,2021-09-07T00:43:21.835+00:00,2021-09-07T12:05:10.826+00:00,,,,9f618daee0b4c4a2e3f2ec441cedcf281364c575,update_techtag_proto,master,,
+gitlab:GitlabMergeRequest:1:118474761,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,23,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,opened,Mark
 contributor_bomb_sweep & test_of_time_functions as 
deprecated,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/23,kagami_,,,23,2021-09-27T06:37:08.002+00:00,,,,,,deprecate_ce_badge_metric,master,,
+gitlab:GitlabMergeRequest:1:120408790,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,24,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 some fields to CaAnalysis and 
CaTask,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/24,liangjingyang,,,24,2021-10-08T06:12:06.684+00:00,2021-10-08T06:12:21.672+00:00,,,,0401d004a0d0aaf3885e6051fc22e1fca44dcee1,add-started-at-and-completed-at,master,,
+gitlab:GitlabMergeRequest:1:122908069,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,25,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 details for 
debug,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/25,kagami_,,,25,2021-10-26T00:43:54.694+00:00,2021-10-26T01:12:37.943+00:00,,,,a2646bb96b70058c11ca1db6dfd200dc8a24a9d3,debug_details,master,,
+gitlab:GitlabMergeRequest:1:123028722,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,26,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 debug mode in request 
parameter,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/26,kagami_,,,26,2021-10-26T14:08:14.439+00:00,2021-10-26T14:08:36.297+00:00,,,,125548e3739b84835662b751c3b72f6b13c74591,debug_mode,master,,
+gitlab:GitlabMergeRequest:1:134847762,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,27,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,closed,add
 aspect ast node 
count,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/27,ShiwenLuo,,,27,2022-01-12T16:18:18.192+00:00,,2022-01-13T13:06:18.100+00:00,,,,add-aspect-ast-node-count,master,,
+gitlab:GitlabMergeRequest:1:69981719,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,1,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 report_object_name to 
AnalysisMessage,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/1,liangjingyang,,,1,2020-09-06T11:20:15.288+00:00,2020-09-06T11:20:53.522+00:00,,,,d64d19e1c6f3c80118f89bc34583416efe5dcfc1,notify-report-url,master,,
+gitlab:GitlabMergeRequest:1:71846142,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,2,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 force_analyze parameter to 
SubmitRepoRequest,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/2,liangjingyang,,,2,2020-09-23T11:16:22.000+00:00,2020-09-23T11:16:40.584+00:00,,,,921791c4f2f26304c7e51eabad1266ef584ffc0e,force-analyze,master,,
+gitlab:GitlabMergeRequest:1:76106237,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,3,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,closed,Add
 commit author info in 
protobuf,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/3,huiqingu,,,3,2020-10-29T09:57:18.574+00:00,,2020-11-16T07:07:36.578+00:00,,,,commit_author,master,,
+gitlab:GitlabMergeRequest:1:76836841,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,4,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 original commit author 
info,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/4,huiqingu,,,4,2020-11-04T13:58:02.637+00:00,2020-11-05T08:16:11.481+00:00,,,,2fce14f9a106764d34a07c28c037623311a76b5e,sqaushed_merge_commit_author,master,,
+gitlab:GitlabMergeRequest:1:79206897,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,5,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 
ContributorBombSweep,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/5,kagami_,,,5,2020-11-24T00:18:11.350+00:00,2020-11-24T02:46:34.983+00:00,,,,dfcd0eb642440ccdafcdd37ed50430514284b420,bomb_sweep,master,,
+gitlab:GitlabMergeRequest:1:79236629,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,6,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Fix
 
syntax,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/6,kagami_,,,6,2020-11-24T02:59:39.585+00:00,2020-11-24T03:00:00.688+00:00,,,,940d7bc03873ef9bfd92d6131e31bc7f05746247,fix_syntax,master,,
+gitlab:GitlabMergeRequest:1:79742054,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,7,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 test of time 
badge,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/7,huiqingu,,,7,2020-11-27T08:17:41.396+00:00,2020-12-01T08:48:40.595+00:00,,,,39ca820d779433cdf737d503ecab768d844f5de3,test_of_time,master,,
+gitlab:GitlabMergeRequest:1:80123152,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,8,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Change
 rank type and rename 
developer_test_of_time,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/8,huiqingu,,,8,2020-12-01T08:58:57.094+00:00,2020-12-01T09:09:34.668+00:00,,,,a7a56a4098094bc4ca2a4a34fb9b0a7940f62756,change_rank_type,master,,
+gitlab:GitlabMergeRequest:1:81364800,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,9,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 
package_to_tags,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/9,kagami_,,,9,2020-12-11T06:07:13.107+00:00,2020-12-11T06:07:40.831+00:00,,,,4aca49223d4f978c63284ca44e45e4fcaaa682f9,package_to_tag,master,,
+gitlab:GitlabMergeRequest:1:81371049,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,10,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Change
 tag_ids to 
tag_names,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/10,kagami_,,,10,2020-12-11T06:57:16.282+00:00,2020-12-11T06:57:24.855+00:00,,,,0f8d2f61e30d7b47e37966f4f706aa95d9413ae1,package_to_tag,master,,
+gitlab:GitlabMergeRequest:1:81379647,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,11,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Finally
 use 
tag_ids,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/11,kagami_,,,11,2020-12-11T08:40:17.471+00:00,2020-12-11T08:40:33.244+00:00,,,,e93f7370d63b5c7b80aa53a9b8973d3a3b646f67,package_to_tag_id,master,,
+gitlab:GitlabMergeRequest:1:83243616,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,12,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 tag for 
report,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/12,huiqingu,,,12,2020-12-30T06:46:52.904+00:00,2020-12-30T06:51:58.005+00:00,,,,378144b4fabf925d3ff97de287affbac39197902,add_tag,master,,
+gitlab:GitlabMergeRequest:1:84599747,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,13,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 cpu. memory and 
timestamps,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/13,ghost1,,,13,2021-01-13T14:13:04.376+00:00,2021-01-13T14:21:45.564+00:00,,,,ecea0b568577f76a83273f081fdb05d9a0cd6dce,add_cpu_mem_time,master,,
+gitlab:GitlabMergeRequest:1:84609384,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,14,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,add
 semi 
colons,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/14,ghost1,,,14,2021-01-13T15:16:54.520+00:00,2021-01-13T15:17:05.858+00:00,,,,7a2a331658f453e650d836e400b767a9c881fbeb,add_cpu_mem_time_fix,master,,
+gitlab:GitlabMergeRequest:1:93412412,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,15,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Refactor
 repeated fields in report_of_all to 
streaming,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/15,liangjingyang,,,15,2021-03-25T07:31:36.715+00:00,2021-04-01T06:52:40.834+00:00,,,,727871ad985bc001b82a0b5bf0d11415a12127cb,refactor-repeated-to-streaming,master,,
+gitlab:GitlabMergeRequest:1:94277896,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,16,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 churned equivalent 
proto,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/16,luosw,,,16,2021-04-01T06:46:34.175+00:00,2021-04-01T07:08:19.183+00:00,,,,2586046536fbdae442e8dd295573bc6bf3a1e2e4,churned-equivalent,master,,
+gitlab:GitlabMergeRequest:1:96157995,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,17,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Add
 combined list to 
SubmitRepoRequest,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/17,liangjingyang,,,17,2021-04-16T02:43:12.214+00:00,2021-04-26T08:46:17.510+00:00,,,,20d7d68963114fda55eb89bc73bd427aac0a22b0,combined-analysis,master,,
+gitlab:GitlabMergeRequest:1:96784148,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,18,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Remove
 original churned deveq & add churned deveq to 
aggregation,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/18,luosw,,,18,2021-04-21T10:11:47.819+00:00,2021-04-21T10:12:17.362+00:00,,,,191c9309d3579498fbf3e76a4b18b7eb15aee24f,churned-equivalent,master,,
+gitlab:GitlabMergeRequest:1:96794553,"{""ConnectionId"":1,""ProjectId"":18524154}",_raw_gitlab_api_merge_requests,19,,gitlab:GitlabProject:1:18524154,gitlab:GitlabProject:1:18524154,merged,Remove
 origin churned 
deveq,,https://gitlab.com/merico-dev/ae/analysis-proto/-/merge_requests/19,luosw,,,19,2021-04-21T11:30:55.426+00:00,2021-04-21T11:31:13.194+00:00,,,,944383b28553ad916f7b46422688e765e803200e,churned-equivalent,master,,
diff --git a/plugins/gitlab/e2e/tables/repos.csv 
b/plugins/gitlab/e2e/snapshot_tables/repos.csv
similarity index 100%
rename from plugins/gitlab/e2e/tables/repos.csv
rename to plugins/gitlab/e2e/snapshot_tables/repos.csv
diff --git a/plugins/gitlab/e2e/tables/_raw_gitlab_api_merge_requests.csv 
b/plugins/gitlab/e2e/tables/_raw_gitlab_api_merge_requests.csv
new file mode 100644
index 00000000..aa47e815
--- /dev/null
+++ b/plugins/gitlab/e2e/tables/_raw_gitlab_api_merge_requests.csv
@@ -0,0 +1,28 @@
+id,params,data,url,input,created_at
+1,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":69981719,""iid"":1,""project_id"":18524154,""title"":""Add
 report_object_name to 
AnalysisMessage"",""description"":"""",""state"":""merged"",""created_at"":""2020-09-06T11:20:15.288Z"",""updated_at"":""2020-09-06T11:20:53.479Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url";
 [...]
+2,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":71846142,""iid"":2,""project_id"":18524154,""title"":""Add
 force_analyze parameter to 
SubmitRepoRequest"",""description"":"""",""state"":""merged"",""created_at"":""2020-09-23T11:16:22.000Z"",""updated_at"":""2020-09-23T11:16:40.543Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""w
 [...]
+3,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":76106237,""iid"":3,""project_id"":18524154,""title"":""Add
 commit author info in 
protobuf"",""description"":"""",""state"":""closed"",""created_at"":""2020-10-29T09:57:18.574Z"",""updated_at"":""2020-11-16T07:07:36.548Z"",""merged_by"":null,""merge_user"":null,""merged_at"":null,""closed_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/- 
[...]
+4,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":76836841,""iid"":4,""project_id"":18524154,""title"":""Add
 original commit author 
info"",""description"":"""",""state"":""merged"",""created_at"":""2020-11-04T13:58:02.637Z"",""updated_at"":""2020-11-05T08:16:11.438Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url"":""https:
 [...]
+5,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":79206897,""iid"":5,""project_id"":18524154,""title"":""Add
 
ContributorBombSweep"",""description"":"""",""state"":""merged"",""created_at"":""2020-11-24T00:18:11.350Z"",""updated_at"":""2020-11-24T02:46:34.929Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url"":""https://gitla
 [...]
+6,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":79236629,""iid"":6,""project_id"":18524154,""title"":""Fix
 
syntax"",""description"":"""",""state"":""merged"",""created_at"":""2020-11-24T02:59:39.585Z"",""updated_at"":""2020-11-24T03:00:00.652Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_url"":""https://git
 [...]
+7,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":79742054,""iid"":7,""project_id"":18524154,""title"":""Add
 test of time 
badge"",""description"":"""",""state"":""merged"",""created_at"":""2020-11-27T08:17:41.396Z"",""updated_at"":""2020-12-01T08:53:21.126Z"",""merged_by"":{""id"":6495855,""username"":""huiqingu"",""name"":""Huiqin
 
Gu"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/64fa1e6f684df098f2c748096893fbcc?s=80\u0026d=identicon"",""web_url"":""ht
 [...]
+8,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":80123152,""iid"":8,""project_id"":18524154,""title"":""Change
 rank type and rename 
developer_test_of_time"",""description"":"""",""state"":""merged"",""created_at"":""2020-12-01T08:58:57.094Z"",""updated_at"":""2020-12-01T09:09:34.612Z"",""merged_by"":{""id"":6495855,""username"":""huiqingu"",""name"":""Huiqin
 
Gu"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/64fa1e6f684df098f2c748096893fbcc?s=80\u0026d=
 [...]
+9,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":81364800,""iid"":9,""project_id"":18524154,""title"":""Add
 
package_to_tags"",""description"":"""",""state"":""merged"",""created_at"":""2020-12-11T06:07:13.107Z"",""updated_at"":""2020-12-11T06:07:40.789Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_url"":""ht
 [...]
+10,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":81371049,""iid"":10,""project_id"":18524154,""title"":""Change
 tag_ids to 
tag_names"",""description"":"""",""state"":""merged"",""created_at"":""2020-12-11T06:57:16.282Z"",""updated_at"":""2020-12-11T06:57:24.290Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_
 [...]
+11,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":81379647,""iid"":11,""project_id"":18524154,""title"":""Finally
 use 
tag_ids"",""description"":"""",""state"":""merged"",""created_at"":""2020-12-11T08:40:17.471Z"",""updated_at"":""2020-12-11T08:40:33.195Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_url"":"";
 [...]
+12,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":83243616,""iid"":12,""project_id"":18524154,""title"":""Add
 tag for 
report"",""description"":"""",""state"":""merged"",""created_at"":""2020-12-30T06:46:52.904Z"",""updated_at"":""2020-12-30T06:51:57.920Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url"":""https://gitlab.co
 [...]
+13,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":84599747,""iid"":13,""project_id"":18524154,""title"":""Add
 cpu. memory and 
timestamps"",""description"":"""",""state"":""merged"",""created_at"":""2021-01-13T14:13:04.376Z"",""updated_at"":""2021-01-13T14:21:45.527Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url"":""https
 [...]
+14,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":84609384,""iid"":14,""project_id"":18524154,""title"":""add
 semi 
colons"",""description"":"""",""state"":""merged"",""created_at"":""2021-01-13T15:16:54.520Z"",""updated_at"":""2021-01-13T15:17:05.824Z"",""merged_by"":null,""merge_user"":null,""merged_at"":""2021-01-13T15:17:05.858Z"",""closed_by"":null,""closed_at"":null,""target_branch"":""master"",""source_branch"":""add_cpu_mem_time_fix"",""user_notes_count"":0,""upvotes"":0,"
 [...]
+15,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":93412412,""iid"":15,""project_id"":18524154,""title"":""Refactor
 repeated fields in report_of_all to 
streaming"",""description"":"""",""state"":""merged"",""created_at"":""2021-03-25T07:31:36.715Z"",""updated_at"":""2021-05-21T13:04:03.055Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.p
 [...]
+16,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":94277896,""iid"":16,""project_id"":18524154,""title"":""Add
 churned equivalent 
proto"",""description"":"""",""state"":""merged"",""created_at"":""2021-04-01T06:46:34.175Z"",""updated_at"":""2021-04-01T07:08:19.137Z"",""merged_by"":{""id"":3406788,""username"":""luosw"",""name"":""Shiwen
 
Luo"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/849b584b0be6e2ab58555276fdb4e565?s=80\u0026d=identicon"",""web_url";
 [...]
+17,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":96157995,""iid"":17,""project_id"":18524154,""title"":""Add
 combined list to 
SubmitRepoRequest"",""description"":"""",""state"":""merged"",""created_at"":""2021-04-16T02:43:12.214Z"",""updated_at"":""2021-04-26T08:46:17.436Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_url"";
 [...]
+18,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":96784148,""iid"":18,""project_id"":18524154,""title"":""Remove
 original churned deveq \u0026 add churned deveq to 
aggregation"",""description"":"""",""state"":""merged"",""created_at"":""2021-04-21T10:11:47.819Z"",""updated_at"":""2021-04-21T10:12:17.286Z"",""merged_by"":{""id"":3406788,""username"":""luosw"",""name"":""Shiwen
 
Luo"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/849b584b0be6e2ab58555276fd
 [...]
+19,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":96794553,""iid"":19,""project_id"":18524154,""title"":""Remove
 origin churned 
deveq"",""description"":"""",""state"":""merged"",""created_at"":""2021-04-21T11:30:55.426Z"",""updated_at"":""2021-04-21T11:31:13.147Z"",""merged_by"":{""id"":3406788,""username"":""luosw"",""name"":""Shiwen
 
Luo"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/849b584b0be6e2ab58555276fdb4e565?s=80\u0026d=identicon"",""web_url"";
 [...]
+20,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":114440893,""iid"":20,""project_id"":18524154,""title"":""Draft:
 Techtag 
proto"",""description"":"""",""state"":""closed"",""created_at"":""2021-08-30T02:00:21.174Z"",""updated_at"":""2021-09-08T05:59:00.006Z"",""merged_by"":null,""merge_user"":null,""merged_at"":null,""closed_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d
 [...]
+21,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":115501302,""iid"":21,""project_id"":18524154,""title"":""Add
 language feature 
proto"",""description"":"""",""state"":""merged"",""created_at"":""2021-09-05T10:36:51.256Z"",""updated_at"":""2021-09-05T10:36:59.371Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_
 [...]
+22,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":115676082,""iid"":22,""project_id"":18524154,""title"":""Update
 tech tag 
proto"",""description"":"""",""state"":""merged"",""created_at"":""2021-09-07T00:43:21.835Z"",""updated_at"":""2021-09-07T12:05:10.797Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_url"";
 [...]
+23,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":118474761,""iid"":23,""project_id"":18524154,""title"":""Mark
 contributor_bomb_sweep \u0026 test_of_time_functions as 
deprecated"",""description"":"""",""state"":""opened"",""created_at"":""2021-09-27T06:37:08.002Z"",""updated_at"":""2021-09-27T06:37:08.002Z"",""merged_by"":null,""merge_user"":null,""merged_at"":null,""closed_by"":null,""closed_at"":null,""target_branch"":""master"",""source_branch"":""deprecate_ce_badge_metric"",
 [...]
+24,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":120408790,""iid"":24,""project_id"":18524154,""title"":""Add
 some fields to CaAnalysis and 
CaTask"",""description"":"""",""state"":""merged"",""created_at"":""2021-10-08T06:12:06.684Z"",""updated_at"":""2021-10-08T06:12:21.646Z"",""merged_by"":{""id"":1678508,""username"":""liangjingyang"",""name"":""Jingyang
 
Liang"",""state"":""active"",""avatar_url"":""https://gitlab.com/uploads/-/system/user/avatar/1678508/avatar.png"",""web_ur
 [...]
+25,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":122908069,""iid"":25,""project_id"":18524154,""title"":""Add
 details for 
debug"",""description"":"""",""state"":""merged"",""created_at"":""2021-10-26T00:43:54.694Z"",""updated_at"":""2021-10-26T01:12:37.911Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon"",""web_url"";
 [...]
+26,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":123028722,""iid"":26,""project_id"":18524154,""title"":""Add
 debug mode in request 
parameter"",""description"":"""",""state"":""merged"",""created_at"":""2021-10-26T14:08:14.439Z"",""updated_at"":""2021-10-26T14:08:36.264Z"",""merged_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b6c79d3ef5f1c92022969a15485?s=80\u0026d=identicon
 [...]
+27,"{""ConnectionId"":1,""ProjectId"":18524154}","{""id"":134847762,""iid"":27,""project_id"":18524154,""title"":""add
 aspect ast node 
count"",""description"":"""",""state"":""closed"",""created_at"":""2022-01-12T16:18:18.192Z"",""updated_at"":""2022-01-13T13:06:18.067Z"",""merged_by"":null,""merge_user"":null,""merged_at"":null,""closed_by"":{""id"":3412597,""username"":""kagami_"",""name"":""Mingjing
 
Liao"",""state"":""active"",""avatar_url"":""https://secure.gravatar.com/avatar/d1d69b
 [...]
diff --git a/plugins/gitlab/tasks/issue_collector.go 
b/plugins/gitlab/tasks/issue_collector.go
index 6f231893..cc5554fe 100644
--- a/plugins/gitlab/tasks/issue_collector.go
+++ b/plugins/gitlab/tasks/issue_collector.go
@@ -57,7 +57,7 @@ func CollectApiIssues(taskCtx core.SubTaskContext) error {
                        dal.Orderby("gitlab_updated_at DESC"),
                }
                err := db.First(&latestUpdated, clause...)
-               if err != nil {
+               if err != nil && err.Error() != "record not found" {
                        return fmt.Errorf("failed to get latest gitlab issue 
record: %w", err)
                }
                if latestUpdated.GitlabId > 0 {
diff --git a/plugins/gitlab/tasks/mr_convertor.go 
b/plugins/gitlab/tasks/mr_convertor.go
index 58a0845d..034f8ab0 100644
--- a/plugins/gitlab/tasks/mr_convertor.go
+++ b/plugins/gitlab/tasks/mr_convertor.go
@@ -41,7 +41,7 @@ func ConvertApiMergeRequests(taskCtx core.SubTaskContext) 
error {
        db := taskCtx.GetDal()
        clauses := []dal.Clause{
                dal.From(&models.GitlabMergeRequest{}),
-               dal.Where("project_id=?", data.Options.ProjectId),
+               dal.Where("project_id=? and connection_id = ?", 
data.Options.ProjectId, data.Options.ConnectionId),
        }
 
        cursor, err := db.Cursor(clauses...)
@@ -63,10 +63,10 @@ func ConvertApiMergeRequests(taskCtx core.SubTaskContext) 
error {
 
                        domainPr := &code.PullRequest{
                                DomainEntity: domainlayer.DomainEntity{
-                                       Id: 
domainMrIdGenerator.Generate(gitlabMr.GitlabId),
+                                       Id: 
domainMrIdGenerator.Generate(data.Options.ConnectionId, gitlabMr.GitlabId),
                                },
-                               BaseRepoId:     
domainRepoIdGenerator.Generate(gitlabMr.SourceProjectId),
-                               HeadRepoId:     
domainRepoIdGenerator.Generate(gitlabMr.TargetProjectId),
+                               BaseRepoId:     
domainRepoIdGenerator.Generate(data.Options.ConnectionId, 
gitlabMr.SourceProjectId),
+                               HeadRepoId:     
domainRepoIdGenerator.Generate(data.Options.ConnectionId, 
gitlabMr.TargetProjectId),
                                Status:         gitlabMr.State,
                                PullRequestKey: gitlabMr.Iid,
                                Title:          gitlabMr.Title,
diff --git a/plugins/gitlab/tasks/mr_enricher.go 
b/plugins/gitlab/tasks/mr_enricher.go
index f1f5e555..7b20fd75 100644
--- a/plugins/gitlab/tasks/mr_enricher.go
+++ b/plugins/gitlab/tasks/mr_enricher.go
@@ -40,7 +40,7 @@ func EnrichMergeRequests(taskCtx core.SubTaskContext) error {
        db := taskCtx.GetDal()
        clauses := []dal.Clause{
                dal.From(&models.GitlabMergeRequest{}),
-               dal.Where("project_id=?", data.Options.ProjectId),
+               dal.Where("project_id=? and connection_id = ?", 
data.Options.ProjectId, data.Options.ConnectionId),
        }
 
        cursor, err := db.Cursor(clauses...)
@@ -61,7 +61,8 @@ func EnrichMergeRequests(taskCtx core.SubTaskContext) error {
                        // `system` = 0 is needed since we only care about 
human comments
                        noteClauses := []dal.Clause{
                                dal.From(&models.GitlabMergeRequestNote{}),
-                               dal.Where("merge_request_id = ? AND is_system = 
?", gitlabMr.GitlabId, false),
+                               dal.Where("merge_request_id = ? AND is_system = 
? AND connection_id = ? ",
+                                       gitlabMr.GitlabId, false, 
data.Options.ConnectionId),
                                dal.Orderby("gitlab_created_at asc"),
                        }
                        err = db.All(&notes, noteClauses...)
@@ -74,7 +75,8 @@ func EnrichMergeRequests(taskCtx core.SubTaskContext) error {
                                dal.From(&models.GitlabCommit{}),
                                dal.Join(`join 
_tool_gitlab_merge_request_commits gmrc 
                                        on gmrc.commit_sha = 
_tool_gitlab_commits.sha`),
-                               dal.Where("merge_request_id = ?", 
gitlabMr.GitlabId),
+                               dal.Where("merge_request_id = ? AND 
connection_id = ?",
+                                       gitlabMr.GitlabId, 
data.Options.ConnectionId),
                                dal.Orderby("authored_date asc"),
                        }
                        err = db.All(&commits, commitClauses...)
diff --git a/plugins/gitlab/tasks/mr_extractor.go 
b/plugins/gitlab/tasks/mr_extractor.go
index f0420e89..b1f144b6 100644
--- a/plugins/gitlab/tasks/mr_extractor.go
+++ b/plugins/gitlab/tasks/mr_extractor.go
@@ -88,11 +88,12 @@ func ExtractApiMergeRequests(taskCtx core.SubTaskContext) 
error {
                                return nil, err
                        }
                        results := make([]interface{}, 0, len(mr.Reviewers)+1)
-
+                       gitlabMergeRequest.ConnectionId = 
data.Options.ConnectionId
                        results = append(results, gitlabMergeRequest)
 
                        for _, reviewer := range mr.Reviewers {
                                gitlabReviewer := &models.GitlabReviewer{
+                                       ConnectionId:   
data.Options.ConnectionId,
                                        GitlabId:       reviewer.GitlabId,
                                        MergeRequestId: mr.GitlabId,
                                        ProjectId:      data.Options.ProjectId,

Reply via email to