klesh commented on code in PR #3690: URL: https://github.com/apache/incubator-devlake/pull/3690#discussion_r1015356588
########## models/migrationscripts/20221107_add_project_xx_meric.go: ########## @@ -0,0 +1,83 @@ +/* +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/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" + "github.com/apache/incubator-devlake/models/migrationscripts/archived" + "github.com/apache/incubator-devlake/plugins/core" +) + +type pullRequest20221107 struct { Review Comment: not necessary ########## models/migrationscripts/20221107_add_project_xx_meric.go: ########## @@ -0,0 +1,83 @@ +/* +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/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" + "github.com/apache/incubator-devlake/models/migrationscripts/archived" + "github.com/apache/incubator-devlake/plugins/core" +) + +type pullRequest20221107 struct { + CodingTimespan *int64 + ReviewLag *int64 + ReviewTimespan *int64 + DeployTimespan *int64 + ChangeTimespan *int64 + OrigCodingTimespan int64 + OrigReviewLag int64 + OrigReviewTimespan int64 + OrigDeployTimespan int64 +} + +func (pullRequest20221107) TableName() string { + return "pull_requests" +} + +type issue20221107 struct { + DeploymentId string `gorm:"type:varchar(255)"` +} + +func (issue20221107) TableName() string { + return "issues" +} + +type addProjectXXMetric struct{} + +func (u *addProjectXXMetric) Up(baseRes core.BasicRes) errors.Error { + db := baseRes.GetDal() + err := migrationhelper.AutoMigrateTables( + baseRes, + &archived.ProjectPrMetrics{}, + &archived.ProjectIssueMetrics{}, + ) + + prColums := []string{ + `coding_timespan`, + `review_lag`, + `review_timespan`, + `deploy_timespan`, + `change_timespan`, + `orig_coding_timespan`, + `orig_review_lag`, + `orig_review_timespan`, + `orig_deploy_timespan`, + } + err = db.DropColumns(pullRequest20221107{}.TableName(), prColums...) + err = db.DropColumns(issue20221107{}.TableName(), `deployment_id`) Review Comment: Same as above ########## models/migrationscripts/20221107_add_project_xx_meric.go: ########## @@ -0,0 +1,83 @@ +/* +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/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" + "github.com/apache/incubator-devlake/models/migrationscripts/archived" + "github.com/apache/incubator-devlake/plugins/core" +) + +type pullRequest20221107 struct { + CodingTimespan *int64 + ReviewLag *int64 + ReviewTimespan *int64 + DeployTimespan *int64 + ChangeTimespan *int64 + OrigCodingTimespan int64 + OrigReviewLag int64 + OrigReviewTimespan int64 + OrigDeployTimespan int64 +} + +func (pullRequest20221107) TableName() string { + return "pull_requests" +} + +type issue20221107 struct { Review Comment: no necessary ########## models/migrationscripts/20221107_add_project_xx_meric.go: ########## @@ -0,0 +1,83 @@ +/* +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/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" + "github.com/apache/incubator-devlake/models/migrationscripts/archived" + "github.com/apache/incubator-devlake/plugins/core" +) + +type pullRequest20221107 struct { + CodingTimespan *int64 + ReviewLag *int64 + ReviewTimespan *int64 + DeployTimespan *int64 + ChangeTimespan *int64 + OrigCodingTimespan int64 + OrigReviewLag int64 + OrigReviewTimespan int64 + OrigDeployTimespan int64 +} + +func (pullRequest20221107) TableName() string { + return "pull_requests" +} + +type issue20221107 struct { + DeploymentId string `gorm:"type:varchar(255)"` +} + +func (issue20221107) TableName() string { + return "issues" +} + +type addProjectXXMetric struct{} + +func (u *addProjectXXMetric) Up(baseRes core.BasicRes) errors.Error { + db := baseRes.GetDal() + err := migrationhelper.AutoMigrateTables( + baseRes, + &archived.ProjectPrMetrics{}, + &archived.ProjectIssueMetrics{}, + ) + + prColums := []string{ + `coding_timespan`, + `review_lag`, + `review_timespan`, + `deploy_timespan`, + `change_timespan`, + `orig_coding_timespan`, + `orig_review_lag`, + `orig_review_timespan`, + `orig_deploy_timespan`, + } + err = db.DropColumns(pullRequest20221107{}.TableName(), prColums...) Review Comment: Just pass "pull_requests" to `db.DropColumns`, the struct is not necessary. ########## plugins/dora/tasks/change_lead_time_calculator.go: ########## @@ -34,9 +34,20 @@ import ( func CalculateChangeLeadTime(taskCtx core.SubTaskContext) errors.Error { db := taskCtx.GetDal() log := taskCtx.GetLogger() + data := taskCtx.GetData().(*DoraTaskData) + repoClauses := []dal.Clause{ Review Comment: The e2ehelper could create tables by CSV files, it should be sufficient for you to do data-mocking. Please do so, curate the data, making sure they are correct in terms of input/output, and diverse enough to prevent algo from processing wrong data-set etc. ########## plugins/dora/tasks/change_lead_time_calculator.go: ########## @@ -34,9 +34,20 @@ import ( func CalculateChangeLeadTime(taskCtx core.SubTaskContext) errors.Error { db := taskCtx.GetDal() log := taskCtx.GetLogger() + data := taskCtx.GetData().(*DoraTaskData) + repoClauses := []dal.Clause{ Review Comment: I suggest that you mock some data and create an e2e-test, and work from there. ########## models/domainlayer/crossdomain/project_pr_metrics.go: ########## @@ -0,0 +1,40 @@ +/* +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 crossdomain + +import ( + "github.com/apache/incubator-devlake/models/domainlayer" +) + +type ProjectPrMetrics struct { Review Comment: missing deploymentId ########## models/migrationscripts/20221107_add_project_xx_meric.go: ########## @@ -0,0 +1,83 @@ +/* +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/errors" + "github.com/apache/incubator-devlake/helpers/migrationhelper" + "github.com/apache/incubator-devlake/models/migrationscripts/archived" + "github.com/apache/incubator-devlake/plugins/core" +) + +type pullRequest20221107 struct { + CodingTimespan *int64 + ReviewLag *int64 + ReviewTimespan *int64 + DeployTimespan *int64 + ChangeTimespan *int64 + OrigCodingTimespan int64 + OrigReviewLag int64 + OrigReviewTimespan int64 + OrigDeployTimespan int64 +} + +func (pullRequest20221107) TableName() string { + return "pull_requests" +} + +type issue20221107 struct { + DeploymentId string `gorm:"type:varchar(255)"` +} + +func (issue20221107) TableName() string { + return "issues" +} + +type addProjectXXMetric struct{} + +func (u *addProjectXXMetric) Up(baseRes core.BasicRes) errors.Error { + db := baseRes.GetDal() + err := migrationhelper.AutoMigrateTables( + baseRes, + &archived.ProjectPrMetrics{}, + &archived.ProjectIssueMetrics{}, + ) + + prColums := []string{ + `coding_timespan`, + `review_lag`, + `review_timespan`, + `deploy_timespan`, + `change_timespan`, + `orig_coding_timespan`, + `orig_review_lag`, + `orig_review_timespan`, + `orig_deploy_timespan`, + } + err = db.DropColumns(pullRequest20221107{}.TableName(), prColums...) + err = db.DropColumns(issue20221107{}.TableName(), `deployment_id`) + return errors.Convert(err) +} + +func (*addProjectXXMetric) Version() uint64 { + return 20221107000001 +} + +func (*addProjectXXMetric) Name() string { + return "add dora project xx metrics" Review Comment: How about "add project metric tables for pr and issues" -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
