INFRA-2887 : SLA breach heads up cron refactor/reimplementation (#411)
* INFRA-2887 : SLA breach heads up cron refactor/reimplementation * INFRA-2887 : Code review comments
This commit is contained in:
@@ -28,7 +28,7 @@ func (service *SeverityService) GetAllActiveSeverities() ([]severity.SeverityDTO
|
||||
return dtoConverter.SeverityEntitiesToDTOs(*severityEntities), err
|
||||
}
|
||||
|
||||
func (service *SeverityService) GetSeverityEscalationMap() (map[uint]*uint, error) {
|
||||
func (service *SeverityService) GetSeverityEscalationMap() (map[uint]*severity.SeverityDTO, error) {
|
||||
severities, err := service.GetAllActiveSeverities()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -49,25 +49,20 @@ func (service *SeverityService) FindSeverityById(severityId uint) (*severity.Sev
|
||||
return &severityDTO, err
|
||||
}
|
||||
|
||||
func (service *SeverityService) createSeverityEscalationMap(severities []severity.SeverityDTO) map[uint]*uint {
|
||||
func (service *SeverityService) createSeverityEscalationMap(severities []severity.SeverityDTO) map[uint]*severity.SeverityDTO {
|
||||
sort.Slice(severities, func(i, j int) bool {
|
||||
return severities[i].Priority > severities[j].Priority
|
||||
})
|
||||
|
||||
escalationMap := make(map[uint]*uint)
|
||||
escalationMap := make(map[uint]*severity.SeverityDTO)
|
||||
|
||||
for index, severity := range severities {
|
||||
var nextSeverityID *uint
|
||||
for nextIndex := index + 1; nextIndex < len(severities); nextIndex++ {
|
||||
if severities[nextIndex].Priority < severity.Priority {
|
||||
nextSeverityID = &severities[nextIndex].ID
|
||||
escalationMap[severity.ID] = &severities[nextIndex]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if nextSeverityID != nil {
|
||||
escalationMap[severity.ID] = nextSeverityID
|
||||
}
|
||||
}
|
||||
|
||||
return escalationMap
|
||||
|
||||
@@ -4,6 +4,6 @@ import "houston/model/severity"
|
||||
|
||||
type ISeverityService interface {
|
||||
GetAllActiveSeverities() ([]severity.SeverityDTO, error)
|
||||
GetSeverityEscalationMap() (map[uint]*uint, error)
|
||||
GetSeverityEscalationMap() (map[uint]*severity.SeverityDTO, error)
|
||||
FindSeverityById(severityId uint) (*severity.SeverityDTO, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user