Skip to content

Commit

Permalink
fix: make some plugin time filed default null (apache#6813)
Browse files Browse the repository at this point in the history
* fix: make some plugin time filed default null

* fix: some plugins e2e test

* fix: jira epic e2e test
  • Loading branch information
abeizn committed Jan 15, 2024
1 parent 0e53cd0 commit 5005d8b
Show file tree
Hide file tree
Showing 48 changed files with 499 additions and 396 deletions.
14 changes: 7 additions & 7 deletions backend/core/models/domainlayer/ticket/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ type Issue struct {
OriginalType string `gorm:"type:varchar(500)"`
Status string `gorm:"type:varchar(100)"`
OriginalStatus string `gorm:"type:varchar(100)"`
StoryPoint float64
StoryPoint *float64
ResolutionDate *time.Time
CreatedDate *time.Time
UpdatedDate *time.Time
LeadTimeMinutes int64
ParentIssueId string `gorm:"type:varchar(255)"`
Priority string `gorm:"type:varchar(255)"`
OriginalEstimateMinutes int64
TimeSpentMinutes int64
TimeRemainingMinutes int64
LeadTimeMinutes *uint
OriginalEstimateMinutes *int64
TimeSpentMinutes *int64
TimeRemainingMinutes *int64
CreatorId string `gorm:"type:varchar(255)"`
CreatorName string `gorm:"type:varchar(255)"`
AssigneeId string `gorm:"type:varchar(255)"`
AssigneeName string `gorm:"type:varchar(255)"`
ParentIssueId string `gorm:"type:varchar(255)"`
Priority string `gorm:"type:varchar(255)"`
Severity string `gorm:"type:varchar(255)"`
Component string `gorm:"type:varchar(255)"`
OriginalProject string `gorm:"type:varchar(255)"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
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/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
)

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

type issue20240115 struct {
LeadTimeMinutes *uint
}

func (issue20240115) TableName() string {
return "issues"
}

type modifyIssueLeadTimeMinutesToUint struct{}

func (u *modifyIssueLeadTimeMinutesToUint) Up(basicRes context.BasicRes) errors.Error {
db := basicRes.GetDal()
if err := migrationhelper.ChangeColumnsType[issue20240115](
basicRes,
u,
issue20240115{}.TableName(),
[]string{"lead_time_minutes"},
func(tmpColumnParams []interface{}) errors.Error {
return db.UpdateColumn(
&issue20240115{},
"lead_time_minutes",
dal.DalClause{Expr: " ? ", Params: tmpColumnParams},
dal.Where("? != 0", tmpColumnParams...),
)
},
); err != nil {
return err
}

return nil
}

func (*modifyIssueLeadTimeMinutesToUint) Version() uint64 {
return 20240115170000
}

func (*modifyIssueLeadTimeMinutesToUint) Name() string {
return "modify issues lead_time_minutes to *uint"
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
if err != nil {
return err
}
err = db.Exec("alter table issues modify lead_time_minutes bigint after updated_date;")
if err != nil {
return err
}
// pull_requests
err = db.Exec("alter table pull_requests modify base_ref varchar(255) after base_repo_id;")
if err != nil {
Expand Down Expand Up @@ -180,7 +184,7 @@ func (*modfiyFieldsSort) Up(baseRes context.BasicRes) errors.Error {
}

func (*modfiyFieldsSort) Version() uint64 {
return 20240108000008
return 20240116000011
}

func (*modfiyFieldsSort) Name() string {
Expand Down
1 change: 1 addition & 0 deletions backend/core/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ func All() []plugin.MigrationScript {
new(modifyIssueOriginalTypeLength),
new(addCommitMsgtoPipelineCommit),
new(modfiyFieldsSort),
new(modifyIssueLeadTimeMinutesToUint),
}
}

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions backend/plugins/bitbucket/e2e/snapshot_tables/issues.csv

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions backend/plugins/bitbucket/models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ limitations under the License.
package models

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

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

type BitbucketIssue struct {
Expand All @@ -38,7 +39,7 @@ type BitbucketIssue struct {
AssigneeId string `gorm:"type:varchar(255)"`
AssigneeName string `gorm:"type:varchar(255)"`
MilestoneId int `gorm:"index"`
LeadTimeMinutes uint
LeadTimeMinutes *uint
Url string `gorm:"type:varchar(255)"`
ClosedAt *time.Time
BitbucketCreatedAt time.Time
Expand Down
7 changes: 4 additions & 3 deletions backend/plugins/bitbucket/tasks/issue_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ limitations under the License.
package tasks

import (
"reflect"
"strconv"

"github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/domainlayer"
Expand All @@ -26,8 +29,6 @@ import (
plugin "github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/bitbucket/models"
"reflect"
"strconv"
)

var ConvertIssuesMeta = plugin.SubTaskMeta{
Expand Down Expand Up @@ -72,8 +73,8 @@ func ConvertIssues(taskCtx plugin.SubTaskContext) errors.Error {
Type: issue.Type,
Status: issue.StdState,
OriginalStatus: issue.State,
LeadTimeMinutes: int64(issue.LeadTimeMinutes),
Url: issue.Url,
LeadTimeMinutes: issue.LeadTimeMinutes,
CreatedDate: &issue.BitbucketCreatedAt,
UpdatedDate: &issue.BitbucketUpdatedAt,
ResolutionDate: issue.ClosedAt,
Expand Down
5 changes: 3 additions & 2 deletions backend/plugins/gitee/models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ limitations under the License.
package models

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

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

type GiteeIssue struct {
Expand All @@ -37,7 +38,7 @@ type GiteeIssue struct {
AuthorName string `gorm:"type:varchar(255)"`
AssigneeId int
AssigneeName string `gorm:"type:varchar(255)"`
LeadTimeMinutes uint
LeadTimeMinutes *uint
Url string `gorm:"type:varchar(255)"`
ClosedAt *time.Time
GiteeCreatedAt time.Time
Expand Down
2 changes: 1 addition & 1 deletion backend/plugins/gitee/tasks/issue_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func ConvertIssues(taskCtx plugin.SubTaskContext) errors.Error {
Type: issue.Type,
AssigneeName: issue.AssigneeName,
CreatorName: issue.AuthorName,
LeadTimeMinutes: int64(issue.LeadTimeMinutes),
LeadTimeMinutes: issue.LeadTimeMinutes,
Url: issue.Url,
CreatedDate: &issue.GiteeCreatedAt,
UpdatedDate: &issue.GiteeUpdatedAt,
Expand Down
3 changes: 2 additions & 1 deletion backend/plugins/gitee/tasks/issue_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ func convertGiteeIssue(issue *IssuesResponse, connectionId uint64, repositoryId
giteeIssue.AuthorName = issue.User.Login
}
if issue.FinishAt != nil {
giteeIssue.LeadTimeMinutes = uint(issue.FinishAt.ToTime().Sub(issue.GiteeCreatedAt.ToTime()).Minutes())
temp := uint(issue.FinishAt.ToTime().Sub(issue.GiteeCreatedAt.ToTime()).Minutes())
giteeIssue.LeadTimeMinutes = &temp
}

return giteeIssue, nil
Expand Down
Loading

0 comments on commit 5005d8b

Please sign in to comment.