TP-0000 | cron job sev fix (#81)
This commit is contained in:
committed by
GitHub Enterprise
parent
68b12f5a14
commit
957f2fa32a
@@ -173,13 +173,19 @@ func postTeamMetrics(socketModeClient *socketmode.Client, db *gorm.DB, logger *z
|
||||
_, _, err = socketModeClient.PostMessage(viper.GetString("cron.job.team_metric_update_channel"), slack.MsgOptionAttachments(attachment))
|
||||
|
||||
for i := 0; i < len(teamsList); i++ {
|
||||
incidents, err := incidentService.GetIncidentsByTeamIdAndNotResolved(teamsList[i].ID)
|
||||
incidents, err := incidentService.GetIncidentsByTeamIdAndNotResolvedAndOfSev0OrSev1(teamsList[i].ID)
|
||||
if err != nil {
|
||||
logger.Error("GetIncidentsByTeamIdAndNotResolved error in cron Job",
|
||||
logger.Error("GetIncidentsByTeamIdAndNotResolvedAndOfSev0OrSev1 error in cron Job",
|
||||
zap.String("cron_name", name), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
incidentsList := *incidents
|
||||
incidentsOpenCount, err := incidentService.GetCountOfIncidentsByTeamIdAndNotResolved(teamsList[i].ID)
|
||||
if err != nil {
|
||||
logger.Error("GetCountOfIncidentsByTeamIdAndNotResolved error in cron Job",
|
||||
zap.String("cron_name", name), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
list := make([]incident.TeamMetricDetailsOfIncident, 0, len(incidentsList))
|
||||
for j := 0; j < len(incidentsList); j++ {
|
||||
@@ -204,7 +210,7 @@ func postTeamMetrics(socketModeClient *socketmode.Client, db *gorm.DB, logger *z
|
||||
}
|
||||
//Post message
|
||||
teamName := builderTeamNameHeader(teamsList[i].Name)
|
||||
openIncidentCount := buildOpenIncidentText(len(incidentsList))
|
||||
openIncidentCount := buildOpenIncidentText(incidentsOpenCount)
|
||||
onCallAndManagerBlock := buildOnCallAndManagerBlock(teamsList[i].OncallHandle, teamsList[i].ManagerHandle)
|
||||
blocks := IncidentMetricBlock(teamName, openIncidentCount, onCallAndManagerBlock)
|
||||
//On the basis of no of incidents, change colour
|
||||
|
||||
@@ -381,10 +381,10 @@ func (r *Repository) FindIncidentsByNotResolvedStatusAndGreaterSeverityTatThanCu
|
||||
return incidentEntity, nil
|
||||
}
|
||||
|
||||
func (r *Repository) GetIncidentsByTeamIdAndNotResolved(team_id uint) (*[]IncidentEntity, error) {
|
||||
func (r *Repository) GetIncidentsByTeamIdAndNotResolvedAndOfSev0OrSev1(team_id uint) (*[]IncidentEntity, error) {
|
||||
var incidentEntity []IncidentEntity
|
||||
|
||||
result := r.gormClient.Order("severity_id").Order("created_at desc").Find(&incidentEntity, "team_id = ? and status <> ?", team_id, 4)
|
||||
result := r.gormClient.Order("severity_id").Order("created_at desc").Find(&incidentEntity, "team_id = ? and status <> ? and severity_id IN ?", team_id, 4, []uint{1, 2})
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
@@ -392,6 +392,17 @@ func (r *Repository) GetIncidentsByTeamIdAndNotResolved(team_id uint) (*[]Incide
|
||||
return &incidentEntity, nil
|
||||
}
|
||||
|
||||
func (r *Repository) GetCountOfIncidentsByTeamIdAndNotResolved(team_id uint) (int, error) {
|
||||
var incidentEntity []IncidentEntity
|
||||
|
||||
result := r.gormClient.Find(&incidentEntity, "team_id = ? and status <> ?", team_id, 4)
|
||||
if result.Error != nil {
|
||||
return 0, result.Error
|
||||
}
|
||||
|
||||
return int(result.RowsAffected), nil
|
||||
}
|
||||
|
||||
func (r *Repository) GetIncidentRoleByIncidentIdAndRole(incident_id uint, role string) (*IncidentRoleEntity, error) {
|
||||
var incidentRoleEntity IncidentRoleEntity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user