Skip to content

incidents: don't load incident recipients twice#424

Closed
yhabteab wants to merge 1 commit into
mainfrom
do-load-incident-recipients-twice
Closed

incidents: don't load incident recipients twice#424
yhabteab wants to merge 1 commit into
mainfrom
do-load-incident-recipients-twice

Conversation

@yhabteab
Copy link
Copy Markdown
Member

The LoadOpenIncidents function already does that for all existing active incidents, so we don't need to re-load them with each ongoing event. This should have been removed with #129 but was overlooked, so we can safely remove it now. Here's the existing code that does the loading of incident recipients for all active incidents:

// Restore incident recipients matching the given incident ids.
err = utils.ForEachRow[ContactRow](ctx, db, "incident_id", incidentIds, func(c *ContactRow) {
incidentsById[c.IncidentID].Recipients[c.Key] = &RecipientState{Role: c.Role}
})

The `LoadOpenIncidents` function already does that for all existing
active incidents, so we don't need to re-load them with each ongoing
event.
@yhabteab yhabteab added this to the 1.0 milestone May 18, 2026
@yhabteab yhabteab added the enhancement New feature or request label May 18, 2026
@cla-bot cla-bot Bot added the cla/signed CLA is signed by all contributors of a PR label May 18, 2026
@yhabteab yhabteab requested a review from oxzi May 18, 2026 14:35
@yhabteab yhabteab moved this from Todo to In progress in Icinga Notifications 1.0 May 18, 2026
@yhabteab
Copy link
Copy Markdown
Member Author

Oh, the branch name says otherwise :)! Please ignore that since I won't recreate this PR just due to the used wrong branch name.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes redundant reloading of incident recipients on every event, since LoadOpenIncidents already loads recipients for active incidents at startup. Cleans up the now-unused restoreRecipients method and simplifies GetCurrent's signature by dropping the ctx parameter.

Changes:

  • Drop the per-event restoreRecipients call in GetCurrent and remove the ctx parameter.
  • Delete the now-unused restoreRecipients method on Incident.
  • Update ProcessEvent to match the new GetCurrent signature.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/incident/incidents.go Simplifies GetCurrent signature and removes redundant recipient reload; updates caller.
internal/incident/incident.go Removes the now-unused restoreRecipients helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yhabteab yhabteab removed this from the 1.0 milestone May 19, 2026
@yhabteab yhabteab removed the request for review from oxzi May 19, 2026 12:22
@yhabteab
Copy link
Copy Markdown
Member Author

Just noticied that this just works as intended 😭! Users are allowed to [un]subscribe from/to and manage incidents from within Icinga Notifications Web, so the recipients role can change from time to time and Icinga Notifications needs to refresh each of the recipients role before processing requests. So closing 🙈!

@yhabteab yhabteab closed this May 19, 2026
@yhabteab yhabteab deleted the do-load-incident-recipients-twice branch May 19, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants