TP-0000 | cron-job desc and oncall tag (#76)
This commit is contained in:
committed by
GitHub Enterprise
parent
0dc924bdd6
commit
f99c5d072b
@@ -2,6 +2,7 @@ package cron
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -180,7 +181,7 @@ func postTeamMetrics(socketModeClient *socketmode.Client, db *gorm.DB, logger *z
|
||||
}
|
||||
incidentsList := *incidents
|
||||
|
||||
list := make([]incident.SlackChannelWithResponderId, 0, len(incidentsList))
|
||||
list := make([]incident.TeamMetricDetailsOfIncident, 0, len(incidentsList))
|
||||
for j := 0; j < len(incidentsList); j++ {
|
||||
//RESPONDER
|
||||
incidentRole, err := incidentService.GetIncidentRoleByIncidentIdAndRole(incidentsList[j].ID, incident.Responder)
|
||||
@@ -191,7 +192,7 @@ func postTeamMetrics(socketModeClient *socketmode.Client, db *gorm.DB, logger *z
|
||||
}
|
||||
|
||||
// map to pojo and to list
|
||||
obj := incident.SlackChannelWithResponderId{
|
||||
obj := incident.TeamMetricDetailsOfIncident{
|
||||
SlackChannel: incidentsList[j].SlackChannel,
|
||||
ResponderId: incidentRole.AssignedTo,
|
||||
CreatedAt: incidentsList[j].CreatedAt,
|
||||
@@ -209,9 +210,16 @@ func postTeamMetrics(socketModeClient *socketmode.Client, db *gorm.DB, logger *z
|
||||
//On the basis of no of incidents, change colour
|
||||
color := util.GetColourByOpenIncidents(len(incidentsList))
|
||||
att := slack.Attachment{Blocks: blocks, Color: color}
|
||||
channelNameForUpdates := viper.GetString("cron.job.team_metric_update_channel")
|
||||
logger.Info("CHANNEL NAME FOR TEAM METRIC UPDATES :", zap.String("channel_name", channelNameForUpdates))
|
||||
_, _, err = socketModeClient.PostMessage(viper.GetString("cron.job.team_metric_update_channel"), slack.MsgOptionAttachments(att))
|
||||
//Tagging OnCall in Reply
|
||||
_, ts, err := socketModeClient.PostMessage(viper.GetString("cron.job.team_metric_update_channel"), slack.MsgOptionAttachments(att))
|
||||
params := slack.PostMessageParameters{
|
||||
ThreadTimestamp: ts,
|
||||
}
|
||||
|
||||
_, _, err = socketModeClient.PostMessage(viper.GetString("cron.job.team_metric_update_channel"), slack.MsgOptionText(fmt.Sprintf("<@%s>", teamsList[i].OncallHandle), false), slack.MsgOptionPostMessageParameters(params))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
text := ""
|
||||
for index := 0; index < len(list); index++ {
|
||||
|
||||
@@ -384,7 +384,7 @@ func (r *Repository) FindIncidentsByNotResolvedStatusAndGreaterSeverityTatThanCu
|
||||
func (r *Repository) GetIncidentsByTeamIdAndNotResolved(team_id uint) (*[]IncidentEntity, error) {
|
||||
var incidentEntity []IncidentEntity
|
||||
|
||||
result := r.gormClient.Order("severity_id").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 <> ?", team_id, 4)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ type AddIncidentStatusRequest struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
type SlackChannelWithResponderId struct {
|
||||
type TeamMetricDetailsOfIncident struct {
|
||||
SlackChannel string `json:"slack_channel,omitempty"`
|
||||
ResponderId string `json:"responder_id,omitempty"`
|
||||
CreatedAt time.Time
|
||||
|
||||
Reference in New Issue
Block a user