Skip to content

Commit

Permalink
fix: the value of incidents priority is P2, but shown in 'HIGH' (#6841)…
Browse files Browse the repository at this point in the history
… (#6843)

* fix: the value of incidents priority is P2, but shown in 'HIGH' in DevLake

* fix: e2e test
  • Loading branch information
abeizn authored Jan 18, 2024
1 parent 5b94e06 commit 78543d1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
1 change: 1 addition & 0 deletions backend/core/models/domainlayer/ticket/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Issue struct {
AssigneeId string `gorm:"type:varchar(255)"`
AssigneeName string `gorm:"type:varchar(255)"`
Severity string `gorm:"type:varchar(255)"`
Urgency 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,52 @@
/*
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 = (*addUrgencyToIssues)(nil)

type issue20240117 struct {
Urgency string `gorm:"type:varchar(255)"`
}

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

type addUrgencyToIssues struct{}

func (u *addUrgencyToIssues) Up(basicRes context.BasicRes) errors.Error {
db := basicRes.GetDal()
if err := db.AutoMigrate(&issue20240117{}); err != nil {
return err
}
return nil
}

func (*addUrgencyToIssues) Version() uint64 {
return 20240117142100
}

func (*addUrgencyToIssues) Name() string {
return "add urgency to issues table"
}
1 change: 1 addition & 0 deletions backend/core/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ func All() []plugin.MigrationScript {
new(addIssueCustomArrayField),
new(removePositionFromPullRequestComments),
new(modifyIssueOriginalTypeLength),
new(addUrgencyToIssues),
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
connection_id,number,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,url,service_id,summary,status,urgency,created_date,updated_date
1,4,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,PIKL83L,[#4] Crash reported,triggered,high,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00
1,5,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,PIKL83L,[#5] Slow startup,acknowledged,high,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00
1,6,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,3,,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,PIKL83L,[#6] Spamming logs,resolved,low,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00
connection_id,number,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,url,service_id,summary,status,urgency,priority,created_date,updated_date
1,4,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,PIKL83L,[#4] Crash reported,triggered,high,,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00
1,5,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,PIKL83L,[#5] Slow startup,acknowledged,high,,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00
1,6,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,3,,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,PIKL83L,[#6] Spamming logs,resolved,low,,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00
8 changes: 4 additions & 4 deletions backend/plugins/pagerduty/e2e/snapshot_tables/issues.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,url,icon_url,issue_key,title,description,epic_key,type,original_type,status,original_status,story_point,resolution_date,created_date,updated_date,lead_time_minutes,parent_issue_id,priority,original_estimate_minutes,time_spent_minutes,time_remaining_minutes,creator_id,creator_name,assignee_id,assignee_name,severity,component
pagerduty:Incident:1:4,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,,4,,[#4] Crash reported,,INCIDENT,,TODO,triggered,0,,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00,0,,high,0,0,0,,,P25K520,Kian Amini,,
pagerduty:Incident:1:5,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,,5,,[#5] Slow startup,,INCIDENT,,IN_PROGRESS,acknowledged,0,,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00,0,,high,0,0,0,,,PQYACO3,Keon Amini,,
pagerduty:Incident:1:6,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,,6,,[#6] Spamming logs,,INCIDENT,,DONE,resolved,0,2022-11-03T06:51:44.000+00:00,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00,6,,low,0,0,0,,,,,,
id,url,icon_url,issue_key,title,description,epic_key,type,original_type,status,original_status,story_point,resolution_date,created_date,updated_date,lead_time_minutes,parent_issue_id,priority,original_estimate_minutes,time_spent_minutes,time_remaining_minutes,creator_id,creator_name,assignee_id,assignee_name,severity,urgency,component
pagerduty:Incident:1:4,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,,4,,[#4] Crash reported,,INCIDENT,,TODO,triggered,0,,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00,0,,,0,0,0,,,P25K520,Kian Amini,,high,
pagerduty:Incident:1:5,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,,5,,[#5] Slow startup,,INCIDENT,,IN_PROGRESS,acknowledged,0,,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00,0,,,0,0,0,,,PQYACO3,Keon Amini,,high,
pagerduty:Incident:1:6,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,,6,,[#6] Spamming logs,,INCIDENT,,DONE,resolved,0,2022-11-03T06:51:44.000+00:00,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00,6,,,0,0,0,,,,,,low,
4 changes: 2 additions & 2 deletions backend/plugins/pagerduty/tasks/incidents_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) errors.Error {
CreatedDate: &incident.CreatedDate,
UpdatedDate: &incident.UpdatedDate,
LeadTimeMinutes: leadTime,
Priority: string(incident.Urgency),
Severity: incident.Priority,
Priority: incident.Priority,
Urgency: string(incident.Urgency),
}
var result []interface{}
if combined.User != nil {
Expand Down

0 comments on commit 78543d1

Please sign in to comment.