Skip to content

Commit 78543d1

Browse files
authored
fix: the value of incidents priority is P2, but shown in 'HIGH' (#6841) (#6843)
* fix: the value of incidents priority is P2, but shown in 'HIGH' in DevLake * fix: e2e test
1 parent 5b94e06 commit 78543d1

File tree

6 files changed

+64
-10
lines changed

6 files changed

+64
-10
lines changed

backend/core/models/domainlayer/ticket/issue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Issue struct {
5050
AssigneeId string `gorm:"type:varchar(255)"`
5151
AssigneeName string `gorm:"type:varchar(255)"`
5252
Severity string `gorm:"type:varchar(255)"`
53+
Urgency string `gorm:"type:varchar(255)"`
5354
Component string `gorm:"type:varchar(255)"`
5455
OriginalProject string `gorm:"type:varchar(255)"`
5556
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package migrationscripts
19+
20+
import (
21+
"github.com/apache/incubator-devlake/core/context"
22+
"github.com/apache/incubator-devlake/core/errors"
23+
"github.com/apache/incubator-devlake/core/plugin"
24+
)
25+
26+
var _ plugin.MigrationScript = (*addUrgencyToIssues)(nil)
27+
28+
type issue20240117 struct {
29+
Urgency string `gorm:"type:varchar(255)"`
30+
}
31+
32+
func (issue20240117) TableName() string {
33+
return "issues"
34+
}
35+
36+
type addUrgencyToIssues struct{}
37+
38+
func (u *addUrgencyToIssues) Up(basicRes context.BasicRes) errors.Error {
39+
db := basicRes.GetDal()
40+
if err := db.AutoMigrate(&issue20240117{}); err != nil {
41+
return err
42+
}
43+
return nil
44+
}
45+
46+
func (*addUrgencyToIssues) Version() uint64 {
47+
return 20240117142100
48+
}
49+
50+
func (*addUrgencyToIssues) Name() string {
51+
return "add urgency to issues table"
52+
}

backend/core/models/migrationscripts/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,6 @@ func All() []plugin.MigrationScript {
9797
new(addIssueCustomArrayField),
9898
new(removePositionFromPullRequestComments),
9999
new(modifyIssueOriginalTypeLength),
100+
new(addUrgencyToIssues),
100101
}
101102
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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
2-
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
3-
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
4-
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
1+
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
2+
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
3+
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
4+
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
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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
2-
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,,
3-
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,,
4-
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,,,,,,
1+
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
2+
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,
3+
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,
4+
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,

backend/plugins/pagerduty/tasks/incidents_converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) errors.Error {
101101
CreatedDate: &incident.CreatedDate,
102102
UpdatedDate: &incident.UpdatedDate,
103103
LeadTimeMinutes: leadTime,
104-
Priority: string(incident.Urgency),
105-
Severity: incident.Priority,
104+
Priority: incident.Priority,
105+
Urgency: string(incident.Urgency),
106106
}
107107
var result []interface{}
108108
if combined.User != nil {

0 commit comments

Comments
 (0)