Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def index

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))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: Added sender: :person to the eager-load so the new From: line (which reads through sender.full_namesender.person) doesn't trigger N+1 queries on the index.

filtered = base_scope.search_by_params(params.to_unsafe_h)
@notifications = filtered.order(created_at: :desc)
.paginate(page: params[:page], per_page: per_page)
Expand Down
7 changes: 4 additions & 3 deletions app/views/notifications/_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<tr>
<th class="px-4 py-3 text-left font-medium text-gray-600">Sent</th>
<!-- <th class="px-4 py-3 text-left font-medium text-gray-600">Kind</th>-->
<th class="px-4 py-3 text-left font-medium text-gray-600">Recipient</th>
<th class="px-4 py-3 text-left font-medium text-gray-600">People</th>
<th class="px-4 py-3 text-left font-medium text-gray-600">Subject</th>
<th class="px-4 py-3 text-left font-medium text-gray-600">Record</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">Responded</th>
Expand All @@ -30,9 +30,10 @@
<%#= notification.kind.to_s.humanize %>
<!-- </td>-->

<!-- Recipient -->
<!-- People -->
<td class="px-4 py-3 text-gray-700">
<%= notification.recipient_email %>
<div><span class="text-xs uppercase text-gray-500">To:</span> <%= notification.recipient_email %></div>
<div class="text-[10px] text-gray-400"><span class="uppercase">From:</span> <%= notification.sender&.full_name.presence || "AWBW portal" %></div>
</td>

<!-- Subject -->
Expand Down