Skip to content

Commit

Permalink
feat: add an original_status field to table pull_requests (#5124)
Browse files Browse the repository at this point in the history
* feat: add an original_status field to table pull_requests

* feat: update gitlab pull requests e2e
  • Loading branch information
abeizn committed May 8, 2023
1 parent 8dc5697 commit 6766111
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 27 deletions.
18 changes: 10 additions & 8 deletions backend/core/models/domainlayer/code/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ limitations under the License.
package code

import (
"github.com/apache/incubator-devlake/core/models/domainlayer"
"time"

"github.com/apache/incubator-devlake/core/models/domainlayer"
)

type PullRequest struct {
domainlayer.DomainEntity
BaseRepoId string `gorm:"index"`
HeadRepoId string `gorm:"index"`
Status string `gorm:"type:varchar(100);comment:open/closed or other"`
Title string
Description string
Url string `gorm:"type:varchar(255)"`
AuthorName string `gorm:"type:varchar(100)"`
BaseRepoId string `gorm:"index"`
HeadRepoId string `gorm:"index"`
Status string `gorm:"type:varchar(100);comment:open/closed or other"`
OriginalStatus string `gorm:"type:varchar(100)"`
Title string
Description string
Url string `gorm:"type:varchar(255)"`
AuthorName string `gorm:"type:varchar(100)"`
//User domainUser.User `gorm:"foreignKey:AuthorId"`
AuthorId string `gorm:"type:varchar(100)"`
ParentPrId string `gorm:"index;type:varchar(100)"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
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 migrationscripts

import (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
)

var _ plugin.MigrationScript = (*addOriginalStatusToPullRequest20230508)(nil)

type addOriginalStatusToPullRequest20230508 struct{}

type pullRequest20230508 struct {
OriginalStatus string `gorm:"type:varchar(100)"`
}

func (pullRequest20230508) TableName() string {
return "pull_requests"
}

func (script *addOriginalStatusToPullRequest20230508) Up(basicRes context.BasicRes) errors.Error {
return basicRes.GetDal().AutoMigrate(&pullRequest20230508{})
}

func (*addOriginalStatusToPullRequest20230508) Version() uint64 {
return 20230508162121
}

func (*addOriginalStatusToPullRequest20230508) Name() string {
return "add original status to pull_requests"
}
1 change: 1 addition & 0 deletions backend/core/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ func All() []plugin.MigrationScript {
new(addCicdDeploymentCommits),
new(renameDeploymentIdForPrProjectMetric),
new(addCommitAuthoredDate),
new(addOriginalStatusToPullRequest20230508),
}
}
38 changes: 19 additions & 19 deletions backend/plugins/gitlab/e2e/snapshot_tables/pull_requests.csv
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
id,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:110817220,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:28584714,merged,Update packages.yml to point to dbt-labs instead of fishtown,With the company name change the old repo is deprecated.,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/16,GJMcClintock,gitlab:GitlabAccount:1:9439881,,16,2021-08-03T15:02:54.955+00:00,2021-08-12T06:12:54.329+00:00,,,,6f45b467c478df1c67d19cf6d4cbb8e05a710662,GJMcClintock-master-patch-24867,master,,
gitlab:GitlabMergeRequest:1:111383524,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:0,closed,The package name changed -> https://hub.getdbt.com/dbt-labs/dbt_utils/latest/,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/17,swiffer,gitlab:GitlabAccount:1:156402,,17,2021-08-07T06:50:25.458+00:00,,2021-08-07T06:51:14.933+00:00,,,,swiffer-master-patch-77533,master,,
gitlab:GitlabMergeRequest:1:114994501,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:29298577,opened,Add support for Snowpipe usage monitoring,Add models and docs for Snowflake pipes (Snowpipe) usage monitoring based on the views in Snowflake Usage schema,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/18,gary-beautypie,gitlab:GitlabAccount:1:9635687,,18,2021-09-01T21:15:30.334+00:00,,,,,,master,master,,
gitlab:GitlabMergeRequest:1:135775405,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:32935405,opened,Updates for dbt 1.0,"This MR sets up the repo for dbt 1.0
id,base_repo_id,head_repo_id,status,original_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:110817220,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:28584714,merged,,Update packages.yml to point to dbt-labs instead of fishtown,With the company name change the old repo is deprecated.,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/16,GJMcClintock,gitlab:GitlabAccount:1:9439881,,16,2021-08-03T15:02:54.955+00:00,2021-08-12T06:12:54.329+00:00,,,,6f45b467c478df1c67d19cf6d4cbb8e05a710662,GJMcClintock-master-patch-24867,master,,
gitlab:GitlabMergeRequest:1:111383524,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:0,closed,,The package name changed -> https://hub.getdbt.com/dbt-labs/dbt_utils/latest/,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/17,swiffer,gitlab:GitlabAccount:1:156402,,17,2021-08-07T06:50:25.458+00:00,,2021-08-07T06:51:14.933+00:00,,,,swiffer-master-patch-77533,master,,
gitlab:GitlabMergeRequest:1:114994501,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:29298577,opened,,Add support for Snowpipe usage monitoring,Add models and docs for Snowflake pipes (Snowpipe) usage monitoring based on the views in Snowflake Usage schema,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/18,gary-beautypie,gitlab:GitlabAccount:1:9635687,,18,2021-09-01T21:15:30.334+00:00,,,,,,master,master,,
gitlab:GitlabMergeRequest:1:135775405,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:32935405,opened,,Updates for dbt 1.0,"This MR sets up the repo for dbt 1.0
A few configs were renamed.

Could a new release be made for dbt 1.0?",https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/19,johnj4,gitlab:GitlabAccount:1:10663622,,19,2022-01-18T19:59:30.723+00:00,,,,,,updates_for_dbt_1.0,master,,
gitlab:GitlabMergeRequest:1:145012495,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:34491818,closed,Draft: Update dbt_project.yml,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/20,PedramNavid,gitlab:GitlabAccount:1:9722492,,20,2022-03-15T03:07:06.077+00:00,,2022-03-15T03:07:22.665+00:00,,,,PedramNavid-master-patch-20645,master,,
gitlab:GitlabMergeRequest:1:158698019,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,opened,Draft: Corrections for dbt 1,Closes https://gitlab.com/gitlab-data/analytics/-/issues/12941,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/21,paul_armstrong,gitlab:GitlabAccount:1:5618371,,21,2022-06-03T09:24:53.707+00:00,,,,,,updates_for_dbt_1_1,master,,
gitlab:GitlabMergeRequest:1:32348491,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,"Resolve ""Add documentation to snowflake spend package""",Closes #1,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/1,emilie,gitlab:GitlabAccount:1:2295562,,1,2019-06-28T05:21:43.743+00:00,2019-06-28T14:32:06.192+00:00,,,,da1d6dea48f5972ffc683da6cff30934e7d6c52c,1-add-documentation-to-snowflake-spend-package,master,,
gitlab:GitlabMergeRequest:1:35064956,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:13835497,merged,Update README to include steps to resolve a potential dbt-utils conflict,Closes #5,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/3,martinguindon,gitlab:GitlabAccount:1:3871284,,3,2019-08-15T19:34:32.706+00:00,2019-08-26T14:15:27.922+00:00,,,,d678bea9d47b42eb13512d1c9d6a592d80b432d4,5-update-readme-to-include-steps-to-resolve-a-potential-dbt-utils-conflict,master,,
gitlab:GitlabMergeRequest:1:35841926,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,"Resolve ""Config is not generic enough""",Closes #4,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/4,emilie,gitlab:GitlabAccount:1:2295562,,4,2019-08-26T15:32:49.557+00:00,2019-08-26T15:37:50.105+00:00,,,,e95b5db25e15a38e21d11cb45cc21bf17d5c407c,4-config-is-not-generic-enough,master,,
gitlab:GitlabMergeRequest:1:53445063,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,merged,Issue 3 Base model,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/5,nehiljain,gitlab:GitlabAccount:1:783199,,5,2020-03-24T12:46:15.891+00:00,2020-03-25T18:36:45.801+00:00,,,,f2ee4cf121a328ce39723506dc18e4661941971a,issue_3,master,,
gitlab:GitlabMergeRequest:1:53627854,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706063,merged,Update schema.yml typo in docs,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/6,nehiljain,gitlab:GitlabAccount:1:783199,,6,2020-03-25T19:02:16.747+00:00,2020-03-25T19:04:19.844+00:00,,,,12dcc23a45adce0b12f8687438ec3a28274c7c30,patch-1,master,,
gitlab:GitlabMergeRequest:1:55146687,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,"Resolve ""Document release process""",Closes #6,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/8,m_walker,gitlab:GitlabAccount:1:5212782,,8,2020-04-08T20:07:10.223+00:00,2020-04-08T20:52:11.150+00:00,,,,7c8245a3a5eda7f502737940aaf7944d99c58f2e,6-document-release-process,master,,
gitlab:GitlabMergeRequest:1:55146787,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,opened,Issue 3: Transformed model for query performance,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/9,nehiljain,gitlab:GitlabAccount:1:783199,,9,2020-04-08T20:09:08.130+00:00,,,,,,issue_3,master,,
gitlab:GitlabMergeRequest:1:58311001,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,Update version in readme,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/10,emilie,gitlab:GitlabAccount:1:2295562,,10,2020-05-11T17:09:12.265+00:00,2020-05-11T17:09:20.603+00:00,,,,66c0f1de49a0c876b8f93e8e0dce3327e766f59d,emilie-master-patch-23079,master,,
gitlab:GitlabMergeRequest:1:62519057,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:19569570,opened,Clustering metering models,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/11,jainnehil,gitlab:GitlabAccount:1:842680,,11,2020-06-24T12:34:04.792+00:00,,,,,,clustering-metering,master,,
gitlab:GitlabMergeRequest:1:65505080,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,"Resolve ""Upgrade package for dbt 0.17""","Closes #11
gitlab:GitlabMergeRequest:1:145012495,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:34491818,closed,,Draft: Update dbt_project.yml,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/20,PedramNavid,gitlab:GitlabAccount:1:9722492,,20,2022-03-15T03:07:06.077+00:00,,2022-03-15T03:07:22.665+00:00,,,,PedramNavid-master-patch-20645,master,,
gitlab:GitlabMergeRequest:1:158698019,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,opened,,Draft: Corrections for dbt 1,Closes https://gitlab.com/gitlab-data/analytics/-/issues/12941,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/21,paul_armstrong,gitlab:GitlabAccount:1:5618371,,21,2022-06-03T09:24:53.707+00:00,,,,,,updates_for_dbt_1_1,master,,
gitlab:GitlabMergeRequest:1:32348491,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,,"Resolve ""Add documentation to snowflake spend package""",Closes #1,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/1,emilie,gitlab:GitlabAccount:1:2295562,,1,2019-06-28T05:21:43.743+00:00,2019-06-28T14:32:06.192+00:00,,,,da1d6dea48f5972ffc683da6cff30934e7d6c52c,1-add-documentation-to-snowflake-spend-package,master,,
gitlab:GitlabMergeRequest:1:35064956,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:13835497,merged,,Update README to include steps to resolve a potential dbt-utils conflict,Closes #5,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/3,martinguindon,gitlab:GitlabAccount:1:3871284,,3,2019-08-15T19:34:32.706+00:00,2019-08-26T14:15:27.922+00:00,,,,d678bea9d47b42eb13512d1c9d6a592d80b432d4,5-update-readme-to-include-steps-to-resolve-a-potential-dbt-utils-conflict,master,,
gitlab:GitlabMergeRequest:1:35841926,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,,"Resolve ""Config is not generic enough""",Closes #4,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/4,emilie,gitlab:GitlabAccount:1:2295562,,4,2019-08-26T15:32:49.557+00:00,2019-08-26T15:37:50.105+00:00,,,,e95b5db25e15a38e21d11cb45cc21bf17d5c407c,4-config-is-not-generic-enough,master,,
gitlab:GitlabMergeRequest:1:53445063,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,merged,,Issue 3 Base model,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/5,nehiljain,gitlab:GitlabAccount:1:783199,,5,2020-03-24T12:46:15.891+00:00,2020-03-25T18:36:45.801+00:00,,,,f2ee4cf121a328ce39723506dc18e4661941971a,issue_3,master,,
gitlab:GitlabMergeRequest:1:53627854,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706063,merged,,Update schema.yml typo in docs,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/6,nehiljain,gitlab:GitlabAccount:1:783199,,6,2020-03-25T19:02:16.747+00:00,2020-03-25T19:04:19.844+00:00,,,,12dcc23a45adce0b12f8687438ec3a28274c7c30,patch-1,master,,
gitlab:GitlabMergeRequest:1:55146687,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,,"Resolve ""Document release process""",Closes #6,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/8,m_walker,gitlab:GitlabAccount:1:5212782,,8,2020-04-08T20:07:10.223+00:00,2020-04-08T20:52:11.150+00:00,,,,7c8245a3a5eda7f502737940aaf7944d99c58f2e,6-document-release-process,master,,
gitlab:GitlabMergeRequest:1:55146787,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,opened,,Issue 3: Transformed model for query performance,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/9,nehiljain,gitlab:GitlabAccount:1:783199,,9,2020-04-08T20:09:08.130+00:00,,,,,,issue_3,master,,
gitlab:GitlabMergeRequest:1:58311001,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,,Update version in readme,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/10,emilie,gitlab:GitlabAccount:1:2295562,,10,2020-05-11T17:09:12.265+00:00,2020-05-11T17:09:20.603+00:00,,,,66c0f1de49a0c876b8f93e8e0dce3327e766f59d,emilie-master-patch-23079,master,,
gitlab:GitlabMergeRequest:1:62519057,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:19569570,opened,,Clustering metering models,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/11,jainnehil,gitlab:GitlabAccount:1:842680,,11,2020-06-24T12:34:04.792+00:00,,,,,,clustering-metering,master,,
gitlab:GitlabMergeRequest:1:65505080,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:12345678,merged,,"Resolve ""Upgrade package for dbt 0.17""","Closes #11

* Upgrades to 0.17.0 format
* Formatting changes to be in line with GitLab SQL Style Guide",https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/12,tayloramurphy,gitlab:GitlabAccount:1:1942272,,12,2020-07-24T17:47:08.238+00:00,2020-07-24T21:13:35.321+00:00,,,,9bfc136eb90802c2ce59956c34dde01bb3de0d50,11-upgrade-package-for-dbt-0-17,master,,
gitlab:GitlabMergeRequest:1:68978485,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,closed,Include more snowflake qrt columns,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/13,aianus,gitlab:GitlabAccount:1:2478227,,13,2020-08-27T20:17:01.825+00:00,,2020-08-27T20:20:08.150+00:00,,,,include_more_snowflake_qrt_columns,master,,
gitlab:GitlabMergeRequest:1:89243644,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:24539973,merged,Update README.md to use the newest version as an example,Update README.md to use the newest version as an example. The old version doesn't work with the current version of dbt,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/14,ThomasLaPiana,gitlab:GitlabAccount:1:2061802,,14,2021-02-19T20:12:14.302+00:00,2021-02-19T20:13:05.969+00:00,,,,21840a7eadb58babe8aeae2960da851a3ed00ddc,ThomasLaPiana-master-patch-93997,master,,
gitlab:GitlabMergeRequest:1:68978485,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:15706315,closed,,Include more snowflake qrt columns,,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/13,aianus,gitlab:GitlabAccount:1:2478227,,13,2020-08-27T20:17:01.825+00:00,,2020-08-27T20:20:08.150+00:00,,,,include_more_snowflake_qrt_columns,master,,
gitlab:GitlabMergeRequest:1:89243644,gitlab:GitlabProject:1:12345678,gitlab:GitlabProject:1:24539973,merged,,Update README.md to use the newest version as an example,Update README.md to use the newest version as an example. The old version doesn't work with the current version of dbt,https://gitlab.com/gitlab-data/snowflake_spend/-/merge_requests/14,ThomasLaPiana,gitlab:GitlabAccount:1:2061802,,14,2021-02-19T20:12:14.302+00:00,2021-02-19T20:13:05.969+00:00,,,,21840a7eadb58babe8aeae2960da851a3ed00ddc,ThomasLaPiana-master-patch-93997,master,,

0 comments on commit 6766111

Please sign in to comment.