Skip to content

N+1 due to missing preload

@digitalmoksha @smcgivern @mdelaossa #34296 (closed)

Same thing as #196249 (closed) the only difference here is that for some reason in #196249 (closed) we can actually use include but here it raises https://api.rubyonrails.org/v5.1/classes/ActiveRecord/EagerLoadPolymorphicError.html

Thus I think it's better to be more robust and consistent in usage.

The iterator is located here:

https://gitlab.com/gitlab-org/gitlab/blob/master/app/views/profiles/notifications/show.html.haml#L52

Solution:

@project_notifications = current_user.notification_settings.preload(source: [:route]).for_projects.order(:id)