* INFRA-2887 : Incident reminder cron refactor/reimplementation * INFRA-2887 : remove cron code * INFRA-2887 : remove comment * INFRA-2887 : Minor changes * INFRA-2887 : PR comments * INFRA-3121 : CLEANUP CRON, remove shedlock table and add UT's * INFRA-2887 : Add default ack * INFRA-2887 : Handler changes
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"houston/appcontext"
|
|
"houston/common/metrics"
|
|
"houston/service/reminder"
|
|
common "houston/service/response/common"
|
|
"net/http"
|
|
)
|
|
|
|
type ReminderHandler struct {
|
|
gin *gin.Engine
|
|
service reminder.ReminderService
|
|
}
|
|
|
|
func NewReminderHandler(
|
|
gin *gin.Engine,
|
|
) *ReminderHandler {
|
|
return &ReminderHandler{
|
|
gin: gin,
|
|
service: appcontext.GetReminderService(),
|
|
}
|
|
}
|
|
|
|
func (handler *ReminderHandler) HandleTeamIncidents(c *gin.Context) {
|
|
err := handler.service.PostTeamIncidents()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, common.ErrorResponse(err, http.StatusInternalServerError, nil))
|
|
metrics.PublishHoustonFlowFailureMetrics("TEAM_INCIDENTS_REMINDER", err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, common.SuccessResponse("Team metrics posted successfully", http.StatusOK))
|
|
}
|
|
|
|
func (handler *ReminderHandler) HandleSlaBreachReminder(c *gin.Context) {
|
|
err := handler.service.PostSlaBreachMessages()
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, common.ErrorResponse(err, http.StatusInternalServerError, nil))
|
|
metrics.PublishHoustonFlowFailureMetrics("SLA_BREACH_REMINDER", err.Error())
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, common.SuccessResponse("SLA breach reminder posted successfully", http.StatusOK))
|
|
}
|
|
|
|
func (handler *ReminderHandler) HandleUserIncidents(c *gin.Context) {
|
|
handler.service.SendIncidentReminder()
|
|
c.JSON(http.StatusOK, common.SuccessResponse("Acknowledged request to send incident reminder", http.StatusOK))
|
|
}
|