You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by "d4x1 (via GitHub)" <gi...@apache.org> on 2023/11/22 06:23:01 UTC

[PR] feat(db): add date relation fields to devops tables [incubator-devlake]

d4x1 opened a new pull request, #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499

   ### ⚠️ Pre Checklist
   
   > Please complete _ALL_ items in this checklist, and remove before submitting
   
   - [x] I have read through the [Contributing Documentation](https://devlake.apache.org/community/).
   - [x] I have added relevant tests.
   - [x] I have added relevant documentation.
   - [x] I will add labels to the PR, such as `pr-type/bug-fix`, `pr-type/feature-development`, etc.
   
   <!--
   Thanks for submitting a pull request!
   
   We appreciate you spending the time to work on these changes.
   Please fill out as many sections below as possible.
   -->
   
   ### Summary
   What does this PR do?
   1. Add some date relation fields to devops tables(details can be seen in #6132 ).
   
   ### Does this close any open issues?
   Closes #6132 
   
   ### Screenshots
   Include any relevant screenshots here.
   
   #### CICDTask
   ##### Before
   <img width="828" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/d337737c-209a-437c-a07b-643a8562b04b">
   
   ##### After
   <img width="829" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/e56a4280-fb04-4fbf-85d1-6251b4661914">
   
   #### CICDPipeline
   ##### Before
   <img width="830" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/a7e70761-9d11-45c2-bd60-c5cfa2a562b3">
   
   ##### After
   <img width="825" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/f053ecb6-a0db-43fc-9075-19f79934288f">
   
   #### CICDDeployment
   ##### Before
   <img width="831" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/3870e7b7-4760-4956-a5c9-7c2138497f59">
   
   ##### After
   <img width="825" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/0927ea88-9ebe-4e3e-ac61-0b03494ab6d0">
   
   #### CICDDeploymentCommit
   ##### Before
   <img width="834" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/c8d9ee45-1683-49d6-9403-ee827685e7a1">
   
   ##### After
   <img width="825" alt="image" src="https://github.com/apache/incubator-devlake/assets/5844806/5c9a4420-0d18-448a-90a0-53f4498017d5">
   
   
   ### Other Information
   Any other information that is important to this PR.
   


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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on code in PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#discussion_r1410258143


##########
backend/core/models/domainlayer/devops/common.go:
##########
@@ -0,0 +1,27 @@
+/*
+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 devops
+
+import "time"
+
+type ItemDateInfo struct {

Review Comment:
   In that case, How about `TaskDates` because all of those structs are Task-alike. 
   and all of the fields are task-related. `Item` is too general.



##########
backend/core/models/migrationscripts/20231122_add_some_date_field_in_devops_tables.go:
##########
@@ -0,0 +1,88 @@
+/*
+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"
+	"time"
+)
+
+var _ plugin.MigrationScript = (*addSomeDateFieldsToDevopsTables)(nil)
+
+type cicdDeployment20231122 struct {
+	QueuedDate *time.Time
+}
+
+func (cicdDeployment20231122) TableName() string {
+	return "cicd_deployments"
+}
+
+type cicdDeploymentCommit20231122 struct {
+	QueuedDate *time.Time
+}
+
+func (cicdDeploymentCommit20231122) TableName() string {
+	return "cicd_deployment_commits"
+}
+
+type cicdPipeline20231122 struct {
+	StartedDate *time.Time
+	QueuedDate  *time.Time
+}
+
+func (cicdPipeline20231122) TableName() string {
+	return "cicd_pipelines"
+}
+
+type cicdTask20231122 struct {
+	CreatedDate time.Time
+	QueuedDate  *time.Time
+}
+
+func (cicdTask20231122) TableName() string {
+	return "cicd_tasks"
+}
+
+type addSomeDateFieldsToDevopsTables struct{}
+
+func (u *addSomeDateFieldsToDevopsTables) Up(basicRes context.BasicRes) errors.Error {
+	db := basicRes.GetDal()
+	if err := db.AutoMigrate(&cicdPipeline20231122{}); err != nil {

Review Comment:
   https://github.com/apache/incubator-devlake/blob/63263ca8cf9d3ea916cbe343367968a2db84b44b/backend/helpers/migrationhelper/migrationhelper.go#L35
   you may like to take a look at this helper, it migrates multiple tables at once



##########
backend/core/models/migrationscripts/20231128_add_queued_duration_sec_field_in_devops_tables.go:
##########
@@ -0,0 +1,85 @@
+/*
+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 = (*addSomeDateFieldsToDevopsTables)(nil)
+
+type cicdDeployment20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdDeployment20231128) TableName() string {
+	return "cicd_deployments"
+}
+
+type cicdDeploymentCommit20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdDeploymentCommit20231128) TableName() string {
+	return "cicd_deployment_commits"
+}
+
+type cicdPipeline20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdPipeline20231128) TableName() string {
+	return "cicd_pipelines"
+}
+
+type cicdTask20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdTask20231128) TableName() string {
+	return "cicd_tasks"
+}
+
+type addQueuedDurationSecFieldToDevopsTables struct{}
+
+func (u *addQueuedDurationSecFieldToDevopsTables) Up(basicRes context.BasicRes) errors.Error {
+	db := basicRes.GetDal()
+	if err := db.AutoMigrate(&cicdPipeline20231128{}); err != nil {

Review Comment:
   same as above



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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on code in PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#discussion_r1410228422


##########
backend/core/models/domainlayer/devops/common.go:
##########
@@ -0,0 +1,27 @@
+/*
+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 devops
+
+import "time"
+
+type ItemDateInfo struct {

Review Comment:
   So far, cicd_tasks\cicd_pipelines\cicd_deployments\cicd_deployment_commints all have these fields.



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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn merged PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499


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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "abeizn (via GitHub)" <gi...@apache.org>.
abeizn commented on code in PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#discussion_r1410195588


##########
backend/core/models/domainlayer/devops/common.go:
##########
@@ -0,0 +1,27 @@
+/*
+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 devops
+
+import "time"
+
+type ItemDateInfo struct {

Review Comment:
   Do all structures used in this have these four values? If not, then wouldn’t the database fields be equivalent to redundant fields?



##########
backend/core/models/domainlayer/devops/common.go:
##########
@@ -0,0 +1,27 @@
+/*
+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 devops
+
+import "time"
+
+type ItemDateInfo struct {

Review Comment:
   Do all structures used in this have these four values? If not, then wouldn’t the database fields be equivalent to redundant fields?



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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on code in PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#discussion_r1410268972


##########
backend/core/models/migrationscripts/20231122_add_some_date_field_in_devops_tables.go:
##########
@@ -0,0 +1,88 @@
+/*
+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"
+	"time"
+)
+
+var _ plugin.MigrationScript = (*addSomeDateFieldsToDevopsTables)(nil)
+
+type cicdDeployment20231122 struct {
+	QueuedDate *time.Time
+}
+
+func (cicdDeployment20231122) TableName() string {
+	return "cicd_deployments"
+}
+
+type cicdDeploymentCommit20231122 struct {
+	QueuedDate *time.Time
+}
+
+func (cicdDeploymentCommit20231122) TableName() string {
+	return "cicd_deployment_commits"
+}
+
+type cicdPipeline20231122 struct {
+	StartedDate *time.Time
+	QueuedDate  *time.Time
+}
+
+func (cicdPipeline20231122) TableName() string {
+	return "cicd_pipelines"
+}
+
+type cicdTask20231122 struct {
+	CreatedDate time.Time
+	QueuedDate  *time.Time
+}
+
+func (cicdTask20231122) TableName() string {
+	return "cicd_tasks"
+}
+
+type addSomeDateFieldsToDevopsTables struct{}
+
+func (u *addSomeDateFieldsToDevopsTables) Up(basicRes context.BasicRes) errors.Error {
+	db := basicRes.GetDal()
+	if err := db.AutoMigrate(&cicdPipeline20231122{}); err != nil {

Review Comment:
   Update it.



##########
backend/core/models/migrationscripts/20231128_add_queued_duration_sec_field_in_devops_tables.go:
##########
@@ -0,0 +1,85 @@
+/*
+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 = (*addSomeDateFieldsToDevopsTables)(nil)
+
+type cicdDeployment20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdDeployment20231128) TableName() string {
+	return "cicd_deployments"
+}
+
+type cicdDeploymentCommit20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdDeploymentCommit20231128) TableName() string {
+	return "cicd_deployment_commits"
+}
+
+type cicdPipeline20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdPipeline20231128) TableName() string {
+	return "cicd_pipelines"
+}
+
+type cicdTask20231128 struct {
+	QueuedDurationSec *float64
+}
+
+func (cicdTask20231128) TableName() string {
+	return "cicd_tasks"
+}
+
+type addQueuedDurationSecFieldToDevopsTables struct{}
+
+func (u *addQueuedDurationSecFieldToDevopsTables) Up(basicRes context.BasicRes) errors.Error {
+	db := basicRes.GetDal()
+	if err := db.AutoMigrate(&cicdPipeline20231128{}); err != nil {

Review Comment:
   Update it.



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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#issuecomment-1831939187

   Circle CI has no UI, so I don't test it.


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


Re: [PR] feat(db): add date relation fields to devops tables [incubator-devlake]

Posted by "d4x1 (via GitHub)" <gi...@apache.org>.
d4x1 commented on code in PR #6499:
URL: https://github.com/apache/incubator-devlake/pull/6499#discussion_r1410364109


##########
backend/core/models/domainlayer/devops/common.go:
##########
@@ -0,0 +1,27 @@
+/*
+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 devops
+
+import "time"
+
+type ItemDateInfo struct {

Review Comment:
   Update it! 



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