diff options
Diffstat (limited to 'app/finders/user_group_notification_settings_finder.rb')
-rw-r--r-- | app/finders/user_group_notification_settings_finder.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/finders/user_group_notification_settings_finder.rb b/app/finders/user_group_notification_settings_finder.rb index a29cf409692..a6f6769116f 100644 --- a/app/finders/user_group_notification_settings_finder.rb +++ b/app/finders/user_group_notification_settings_finder.rb @@ -7,7 +7,9 @@ class UserGroupNotificationSettingsFinder end def execute - groups_with_ancestors = Gitlab::ObjectHierarchy.new(groups).base_and_ancestors + # rubocop: disable CodeReuse/ActiveRecord + groups_with_ancestors = Gitlab::ObjectHierarchy.new(Group.where(id: groups.select(:id))).base_and_ancestors + # rubocop: enable CodeReuse/ActiveRecord @loaded_groups_with_ancestors = groups_with_ancestors.index_by(&:id) @loaded_notification_settings = user.notification_settings_for_groups(groups_with_ancestors).preload_source_route.index_by(&:source_id) @@ -27,6 +29,8 @@ class UserGroupNotificationSettingsFinder parent_setting = loaded_notification_settings[group.parent_id] + return user.notification_settings.build(source: group) unless parent_setting + if should_copy?(parent_setting) user.notification_settings.build(source: group) do |ns| ns.assign_attributes(parent_setting.slice(*NotificationSetting.allowed_fields)) |