Skip to content

Commit 65cbe82

Browse files
fix(webhook): set resolution_date and lead_time_minutes on incident close (#8919)
1 parent f488841 commit 65cbe82

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

backend/plugins/webhook/api/issues.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ func closeIssue(input *plugin.ApiResourceInput, err errors.Error, connection *mo
265265
}
266266
domainIssue.Status = ticket.DONE
267267
domainIssue.OriginalStatus = ``
268+
now := time.Now()
269+
if domainIssue.ResolutionDate == nil {
270+
domainIssue.ResolutionDate = &now
271+
}
272+
if domainIssue.LeadTimeMinutes == nil || *domainIssue.LeadTimeMinutes == 0 {
273+
if domainIssue.CreatedDate != nil {
274+
temp := uint(domainIssue.ResolutionDate.Sub(*domainIssue.CreatedDate).Minutes())
275+
domainIssue.LeadTimeMinutes = &temp
276+
}
277+
}
268278
// save
269279
err = tx.Update(domainIssue)
270280
if err != nil {
@@ -278,6 +288,15 @@ func closeIssue(input *plugin.ApiResourceInput, err errors.Error, connection *mo
278288
if err == nil {
279289
domainIncident.Status = ticket.DONE
280290
domainIncident.OriginalStatus = ``
291+
if domainIncident.ResolutionDate == nil {
292+
domainIncident.ResolutionDate = &now
293+
}
294+
if domainIncident.LeadTimeMinutes == nil || *domainIncident.LeadTimeMinutes == 0 {
295+
if domainIncident.CreatedDate != nil {
296+
temp := uint(domainIncident.ResolutionDate.Sub(*domainIncident.CreatedDate).Minutes())
297+
domainIncident.LeadTimeMinutes = &temp
298+
}
299+
}
281300
// save
282301
err = tx.Update(domainIncident)
283302
if err != nil {

0 commit comments

Comments
 (0)