Show sender on notifications index#1601
Merged
Merged
Conversation
Surfaces who sent each notification so staff can distinguish portal-generated emails from staff-sent ones at a glance, rather than opening each record. Eager-loads the sender to avoid N+1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
maebeale
commented
Jun 8, 2026
| if turbo_frame_request? | ||
| per_page = params[:number_of_items_per_page].presence || 25 | ||
| base_scope = authorized_scope(Notification.includes(:noticeable)) | ||
| base_scope = authorized_scope(Notification.includes(:noticeable, sender: :person)) |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: Added sender: :person to the eager-load so the new From: line (which reads through sender.full_name → sender.person) doesn't trigger N+1 queries on the index.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the goal of this PR and why is this important?
How did you approach the change?
To: [recipient email]and a smaller, lighterFrom: [sender name].Fromfalls back to AWBW portal when a notification has no sender (the association is optional).sender: :personin the controller so the newFromline doesn't trigger N+1 queries.UI Testing Checklist
Anything else to add?
Fromline usessender.full_name, which falls back to the sender's email when their person/name is blank.