Explorar o código

fix set sent_at on complete

Marcus Efraimsson %!s(int64=7) %!d(string=hai) anos
pai
achega
67c58fa5e4

+ 1 - 1
pkg/services/alerting/notifier.go

@@ -68,7 +68,7 @@ func (n *notificationService) sendAndMarkAsComplete(evalContext *EvalContext, no
 	if err != nil {
 		n.log.Error("failed to send notification", "id", not.GetNotifierId())
 	} else {
-		notifierState.state.SentAt = time.Now().Unix()
+		notifierState.state.SentAt = time.Now().UTC().Unix()
 	}
 
 	if evalContext.IsTestRun {

+ 3 - 2
pkg/services/sqlstore/alert_notification.go

@@ -264,11 +264,12 @@ func SetAlertNotificationStateToCompleteCommand(ctx context.Context, cmd *m.SetA
 
 		sql := `UPDATE alert_notification_state SET
 			state = ?,
-			version = ?
+			version = ?,
+			sent_at = ?
 		WHERE
 			id = ?`
 
-		_, err := sess.Exec(sql, cmd.State.State, cmd.State.Version, cmd.State.Id)
+		_, err := sess.Exec(sql, cmd.State.State, cmd.State.Version, cmd.State.SentAt, cmd.State.Id)
 
 		if err != nil {
 			return err