Class: UserGroupNotificationSettingsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/user_group_notification_settings_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, groups) ⇒ UserGroupNotificationSettingsFinder

Returns a new instance of UserGroupNotificationSettingsFinder.



4
5
6
7
# File 'app/finders/user_group_notification_settings_finder.rb', line 4

def initialize(user, groups)
  @user = user
  @groups = groups
end

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/finders/user_group_notification_settings_finder.rb', line 9

def execute
  groups_with_ancestors = groups.self_and_ancestors
  @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)

  preload_emails_disabled

  groups.map do |group|
    find_notification_setting_for(group)
  end
end