You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "Startrekzky (via GitHub)" <gi...@apache.org> on 2024/01/08 09:33:06 UTC
Re: [PR] fix: adjust some fields sort in tables [incubator-devlake]
Startrekzky commented on code in PR #6761:
URL: https://github.com/apache/incubator-devlake/pull/6761#discussion_r1444326969
##########
backend/core/models/migrationscripts/20240108_modify_fileds_sort.go:
##########
@@ -0,0 +1,153 @@
+/*
+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 (
+ "net/url"
+
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+)
+
+type modfiyFieldsSort struct{}
+
+func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
+ dbUrl := baseRes.GetConfig("DB_URL")
+ if dbUrl == "" {
+ return errors.BadInput.New("DB_URL is required")
+ }
+ u, errParse := url.Parse(dbUrl)
+ if errParse != nil {
+ return errors.Convert(errParse)
+ }
+ db := baseRes.GetDal()
+ if u.Scheme == "mysql" {
+ // issues
+ err := db.Exec("alter table issues modify original_type varchar(500) after type;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table issues modify story_point DOUBLE after original_status;")
+ if err != nil {
+ return err
+ }
+ // pull_requests
+ err = db.Exec("alter table pull_requests modify original_status varchar(100) after status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify type varchar(100) after original_status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify component varchar(100) after type;")
+ if err != nil {
+ return err
+ }
+ // cicd deployment commits
+ err = db.Exec("alter table cicd_deployment_commits modify original_status varchar(100) after status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify original_result varchar(100) after result;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify duration_sec DOUBLE after finished_date;")
Review Comment:
The time fields' order is:
- created_date
- queued_date
- queued_duration_sec
- started_date
- finished_date
- duration_sec

##########
backend/core/models/migrationscripts/20240108_modify_fileds_sort.go:
##########
@@ -0,0 +1,153 @@
+/*
+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 (
+ "net/url"
+
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+)
+
+type modfiyFieldsSort struct{}
+
+func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
+ dbUrl := baseRes.GetConfig("DB_URL")
+ if dbUrl == "" {
+ return errors.BadInput.New("DB_URL is required")
+ }
+ u, errParse := url.Parse(dbUrl)
+ if errParse != nil {
+ return errors.Convert(errParse)
+ }
+ db := baseRes.GetDal()
+ if u.Scheme == "mysql" {
+ // issues
+ err := db.Exec("alter table issues modify original_type varchar(500) after type;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table issues modify story_point DOUBLE after original_status;")
Review Comment:
Move `story_point` after `priority`?

##########
backend/core/models/migrationscripts/20240108_modify_fileds_sort.go:
##########
@@ -0,0 +1,153 @@
+/*
+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 (
+ "net/url"
+
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+)
+
+type modfiyFieldsSort struct{}
+
+func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
+ dbUrl := baseRes.GetConfig("DB_URL")
+ if dbUrl == "" {
+ return errors.BadInput.New("DB_URL is required")
+ }
+ u, errParse := url.Parse(dbUrl)
+ if errParse != nil {
+ return errors.Convert(errParse)
+ }
+ db := baseRes.GetDal()
+ if u.Scheme == "mysql" {
+ // issues
+ err := db.Exec("alter table issues modify original_type varchar(500) after type;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table issues modify story_point DOUBLE after original_status;")
+ if err != nil {
+ return err
+ }
+ // pull_requests
+ err = db.Exec("alter table pull_requests modify original_status varchar(100) after status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify type varchar(100) after original_status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify component varchar(100) after type;")
+ if err != nil {
+ return err
+ }
+ // cicd deployment commits
+ err = db.Exec("alter table cicd_deployment_commits modify original_status varchar(100) after status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify original_result varchar(100) after result;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify duration_sec DOUBLE after finished_date;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify queued_date DATETIME after duration_sec;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table cicd_deployment_commits modify queued_duration_sec DOUBLE after queued_date;")
+ if err != nil {
+ return err
+ }
+ // cicd deployments
+ err = db.Exec("alter table cicd_deployments modify original_status varchar(100) after status;")
Review Comment:
The time fields' order is the same as the cicd_deployment_commits:
- created_date
- queued_date
- queued_duration_sec
- started_date
- finished_date
- duration_sec
##########
backend/core/models/migrationscripts/20240108_modify_fileds_sort.go:
##########
@@ -0,0 +1,153 @@
+/*
+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 (
+ "net/url"
+
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+)
+
+type modfiyFieldsSort struct{}
+
+func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
+ dbUrl := baseRes.GetConfig("DB_URL")
+ if dbUrl == "" {
+ return errors.BadInput.New("DB_URL is required")
+ }
+ u, errParse := url.Parse(dbUrl)
+ if errParse != nil {
+ return errors.Convert(errParse)
+ }
+ db := baseRes.GetDal()
+ if u.Scheme == "mysql" {
+ // issues
+ err := db.Exec("alter table issues modify original_type varchar(500) after type;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table issues modify story_point DOUBLE after original_status;")
+ if err != nil {
+ return err
+ }
+ // pull_requests
+ err = db.Exec("alter table pull_requests modify original_status varchar(100) after status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify type varchar(100) after original_status;")
+ if err != nil {
+ return err
+ }
+ err = db.Exec("alter table pull_requests modify component varchar(100) after type;")
+ if err != nil {
+ return err
+ }
Review Comment:
Please also move the ref and commit_sha fields forward. The order is:
- base_repo_id
- base_ref
- base_commit_sha
- head_repo_id
- head_ref
- head_commit_sha
- merge_commit_sha

--
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