From 78543d19d46bfb3e3fd8a31d5143c2a7457f678b Mon Sep 17 00:00:00 2001 From: abeizn Date: Thu, 18 Jan 2024 15:54:40 +0800 Subject: [PATCH] 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 --- .../core/models/domainlayer/ticket/issue.go | 1 + .../20240117_add_urgency_to_issues.go | 52 +++++++++++++++++++ .../core/models/migrationscripts/register.go | 1 + .../_tool_pagerduty_incidents.csv | 8 +-- .../pagerduty/e2e/snapshot_tables/issues.csv | 8 +-- .../pagerduty/tasks/incidents_converter.go | 4 +- 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 backend/core/models/migrationscripts/20240117_add_urgency_to_issues.go diff --git a/backend/core/models/domainlayer/ticket/issue.go b/backend/core/models/domainlayer/ticket/issue.go index 1ef02d4a651..a9f473bf2c7 100644 --- a/backend/core/models/domainlayer/ticket/issue.go +++ b/backend/core/models/domainlayer/ticket/issue.go @@ -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)"` } diff --git a/backend/core/models/migrationscripts/20240117_add_urgency_to_issues.go b/backend/core/models/migrationscripts/20240117_add_urgency_to_issues.go new file mode 100644 index 00000000000..24af60c2e7a --- /dev/null +++ b/backend/core/models/migrationscripts/20240117_add_urgency_to_issues.go @@ -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" +} diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go index 89eef2698dc..dc101ea9864 100644 --- a/backend/core/models/migrationscripts/register.go +++ b/backend/core/models/migrationscripts/register.go @@ -97,5 +97,6 @@ func All() []plugin.MigrationScript { new(addIssueCustomArrayField), new(removePositionFromPullRequestComments), new(modifyIssueOriginalTypeLength), + new(addUrgencyToIssues), } } diff --git a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv index 539209e204a..5e79870fd05 100644 --- a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv +++ b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv @@ -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 diff --git a/backend/plugins/pagerduty/e2e/snapshot_tables/issues.csv b/backend/plugins/pagerduty/e2e/snapshot_tables/issues.csv index da50e2d19d8..03fb0344267 100644 --- a/backend/plugins/pagerduty/e2e/snapshot_tables/issues.csv +++ b/backend/plugins/pagerduty/e2e/snapshot_tables/issues.csv @@ -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, diff --git a/backend/plugins/pagerduty/tasks/incidents_converter.go b/backend/plugins/pagerduty/tasks/incidents_converter.go index 902fdb9ba3e..f7b052b0319 100644 --- a/backend/plugins/pagerduty/tasks/incidents_converter.go +++ b/backend/plugins/pagerduty/tasks/incidents_converter.go @@ -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 {