Skip to content

Commit

Permalink
fix removed notification logs
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Nov 7, 2023
1 parent d089952 commit 3c92154
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions database/redis/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,24 @@ func getLimitedNotifications(

// Helper function for logging information on removed notifications
func logRemovedNotifications(logger moira.Logger, removedNotifications []*moira.ScheduledNotification) {
removedNotificationsTriggerIDs := make([]string, 0, len(removedNotifications))
triggerIDsSet := make(map[string]struct{}, len(removedNotifications))
for _, removedNotification := range removedNotifications {
if removedNotification != nil {
removedNotificationsTriggerIDs = append(removedNotificationsTriggerIDs, removedNotification.Trigger.ID)
if removedNotification == nil {
continue
}

if _, ok := triggerIDsSet[removedNotification.Trigger.ID]; !ok {
triggerIDsSet[removedNotification.Trigger.ID] = struct{}{}
}
}

triggerIDs := make([]string, 0, len(triggerIDsSet))
for triggerID := range triggerIDsSet {
triggerIDs = append(triggerIDs, triggerID)
}

logger.Info().
Interface("removed_notifications_trigger_ids", removedNotificationsTriggerIDs).
Interface("notification_trigger_ids", triggerIDs).
Int("removed_count", len(removedNotifications)).
Msg("Remove notifications in transaction")
}
Expand Down

0 comments on commit 3c92154

Please sign in to comment.