INFRA-3009 : Exclude monitoring state incidents from auto escalation (#395)
* INFRA-3009 : Exclude monitoring state incidents from auto escalation * INFRA-3009 : Constant for sla statuses
This commit is contained in:
@@ -644,7 +644,7 @@ func (r *Repository) FindIncidentsByNotResolvedStatusAndGreaterSeverityTatThanCu
|
||||
currentTime := time.Now()
|
||||
|
||||
result := r.gormClient.Table("incident").
|
||||
Where("incident_status.name <> ? and incident_status.name <> ? and incident.severity_tat <= ? and severity.id <> ?", Resolved, Duplicated, currentTime, 1).
|
||||
Where("incident_status.name <> ? and incident_status.name <> ? and incident_status.name <> ? and incident.severity_tat <= ? and severity.id <> ?", Resolved, Duplicated, Monitoring, currentTime, 1).
|
||||
Joins("JOIN severity ON severity.id = incident.severity_id").
|
||||
Joins("JOIN incident_status on incident.status = incident_status.id").
|
||||
Select("incident.*").
|
||||
@@ -752,7 +752,7 @@ func (r *Repository) FetchAllNonTerminalIncidentStatuses() (*[]IncidentStatusEnt
|
||||
|
||||
func (r *Repository) FetchAllOpenIncidentsWithSeverityTATGreaterThan(slaStart, slaEnd string, severityId ...int) (*[]IncidentEntity, error) {
|
||||
var incidents []IncidentEntity
|
||||
query := fmt.Sprintf("SELECT * FROM incident WHERE severity_tat >= '%v' AND severity_tat < '%v' AND severity_id IN (%v) AND status IN (SELECT id FROM incident_status WHERE is_terminal_status = false) ORDER BY team_id;", slaStart, slaEnd, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(severityId)), ","), "[]"))
|
||||
query := fmt.Sprintf("SELECT * FROM incident WHERE severity_tat >= '%v' AND severity_tat < '%v' AND severity_id IN (%v) AND status IN (%s) ORDER BY team_id;", slaStart, slaEnd, strings.Trim(strings.Join(strings.Fields(fmt.Sprint(severityId)), ","), "[]"), SLA_BREACH_ALLOWED_STATUSES)
|
||||
logger.Info("Query: ", zap.String("query", query))
|
||||
result := r.gormClient.Raw(query).Scan(&incidents)
|
||||
if result.Error != nil {
|
||||
@@ -805,3 +805,7 @@ func buildIntervalExpr(severityIdToArchivalHoursMap map[int]int) string {
|
||||
severityIdToArchivalHoursMap[4],
|
||||
)
|
||||
}
|
||||
|
||||
const (
|
||||
SLA_BREACH_ALLOWED_STATUSES = "1,2"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user