You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ka...@apache.org on 2023/05/19 07:07:05 UTC

[incubator-devlake] branch release-v0.17 updated (d997a6ea9 -> 7c013616b)

This is an automated email from the ASF dual-hosted git repository.

ka94 pushed a change to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


 discard d997a6ea9 [fix-5233]: Pagerduty MTTR computation fix (#5229)
     new 7c013616b [fix-5233]: Pagerduty MTTR computation fix (#5229)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d997a6ea9)
            \
             N -- N -- N   refs/heads/release-v0.17 (7c013616b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 backend/plugins/pagerduty/tasks/service_converter.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


[incubator-devlake] 01/01: [fix-5233]: Pagerduty MTTR computation fix (#5229)

Posted by ka...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ka94 pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 7c013616bc4d59a8908cd9aac86d276ab73c9fd4
Author: Keon Amini <ke...@merico.dev>
AuthorDate: Thu May 18 17:06:43 2023 -0500

    [fix-5233]: Pagerduty MTTR computation fix (#5229)
    
    * fix: Pagerduty now writes to the boards tables to correctly compute MTTR for DORA
    
    * fix: remove cicd scope
---
 backend/plugins/pagerduty/impl/impl.go             |  1 +
 .../plugins/pagerduty/tasks/incidents_converter.go |  6 ++
 .../plugins/pagerduty/tasks/service_converter.go   | 83 ++++++++++++++++++++++
 3 files changed, 90 insertions(+)

diff --git a/backend/plugins/pagerduty/impl/impl.go b/backend/plugins/pagerduty/impl/impl.go
index d669e7e82..6362ba4c0 100644
--- a/backend/plugins/pagerduty/impl/impl.go
+++ b/backend/plugins/pagerduty/impl/impl.go
@@ -54,6 +54,7 @@ func (p PagerDuty) SubTaskMetas() []plugin.SubTaskMeta {
 		tasks.CollectIncidentsMeta,
 		tasks.ExtractIncidentsMeta,
 		tasks.ConvertIncidentsMeta,
+		tasks.ConvertServicesMeta,
 	}
 }
 
diff --git a/backend/plugins/pagerduty/tasks/incidents_converter.go b/backend/plugins/pagerduty/tasks/incidents_converter.go
index 4f1d4bc9a..2c7f8895a 100644
--- a/backend/plugins/pagerduty/tasks/incidents_converter.go
+++ b/backend/plugins/pagerduty/tasks/incidents_converter.go
@@ -66,6 +66,7 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) errors.Error {
 	defer cursor.Close()
 	seenIncidents := map[int]*IncidentWithUser{}
 	idGen := didgen.NewDomainIdGenerator(&models.Incident{})
+	serviceIdGen := didgen.NewDomainIdGenerator(&models.Service{})
 	converter, err := api.NewDataConverter(api.DataConverterArgs{
 		RawDataSubTaskArgs: api.RawDataSubTaskArgs{
 			Ctx: taskCtx,
@@ -107,7 +108,12 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) errors.Error {
 				AssigneeName:    user.Name,
 			}
 			seenIncidents[incident.Number] = combined
+			boardIssue := &ticket.BoardIssue{
+				BoardId: serviceIdGen.Generate(data.Options.ConnectionId, data.Options.ServiceId),
+				IssueId: domainIssue.Id,
+			}
 			return []interface{}{
+				boardIssue,
 				domainIssue,
 			}, nil
 		},
diff --git a/backend/plugins/pagerduty/tasks/service_converter.go b/backend/plugins/pagerduty/tasks/service_converter.go
new file mode 100644
index 000000000..f4114dc52
--- /dev/null
+++ b/backend/plugins/pagerduty/tasks/service_converter.go
@@ -0,0 +1,83 @@
+/*
+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 tasks
+
+import (
+	"github.com/apache/incubator-devlake/core/dal"
+	"github.com/apache/incubator-devlake/core/errors"
+	"github.com/apache/incubator-devlake/core/models/domainlayer"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
+	"github.com/apache/incubator-devlake/core/models/domainlayer/ticket"
+	"github.com/apache/incubator-devlake/core/plugin"
+	helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+	"github.com/apache/incubator-devlake/plugins/pagerduty/models"
+	"reflect"
+)
+
+func ConvertServices(taskCtx plugin.SubTaskContext) errors.Error {
+	db := taskCtx.GetDal()
+	data := taskCtx.GetData().(*PagerDutyTaskData)
+	rawDataSubTaskArgs := &helper.RawDataSubTaskArgs{
+		Ctx: taskCtx,
+		Params: PagerDutyParams{
+			ConnectionId: data.Options.ConnectionId,
+		},
+		Table: "pagerduty_services",
+	}
+	clauses := []dal.Clause{
+		dal.Select("services.*"),
+		dal.From("_tool_pagerduty_services services"),
+		dal.Where("id = ? and connection_id = ?", data.Options.ServiceId, data.Options.ConnectionId),
+	}
+	cursor, err := db.Cursor(clauses...)
+	if err != nil {
+		return err
+	}
+	defer cursor.Close()
+
+	converter, err := helper.NewDataConverter(helper.DataConverterArgs{
+		RawDataSubTaskArgs: *rawDataSubTaskArgs,
+		InputRowType:       reflect.TypeOf(models.Service{}),
+		Input:              cursor,
+		Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
+			service := inputRow.(*models.Service)
+			domainBoard := &ticket.Board{
+				DomainEntity: domainlayer.DomainEntity{
+					Id: didgen.NewDomainIdGenerator(service).Generate(service.ConnectionId, service.Id),
+				},
+				Name: service.Name,
+				Url:  service.Url,
+			}
+			return []interface{}{
+				domainBoard,
+			}, nil
+		},
+	})
+	if err != nil {
+		return err
+	}
+	return converter.Execute()
+}
+
+var ConvertServicesMeta = plugin.SubTaskMeta{
+	Name:             "convertServices",
+	EntryPoint:       ConvertServices,
+	EnabledByDefault: true,
+	Description:      "Convert PagerDuty services",
+	DomainTypes:      []string{plugin.DOMAIN_TYPE_TICKET},
+}