summaryrefslogtreecommitdiff
path: root/app/services/notification_recipient_service.rb
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-07-26 09:33:01 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2017-08-03 09:07:18 -0700
commit46d0bfdcb982d76b8595921a956b088df1573905 (patch)
tree279372fad4d2d3b69022b7519d8943f54cd21998 /app/services/notification_recipient_service.rb
parent651f50ac00bdf14ae660af0fea3d463d07d8d25f (diff)
downloadgitlab-ce-46d0bfdcb982d76b8595921a956b088df1573905.tar.gz
use intersection and diff operators instead of each
Diffstat (limited to 'app/services/notification_recipient_service.rb')
-rw-r--r--app/services/notification_recipient_service.rb24
1 files changed, 2 insertions, 22 deletions
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index b286cc373bd..6b4e97aaab4 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -157,35 +157,15 @@ module NotificationRecipientService
user_ids = user_ids_notifiable_on(project, :watch)
# If project setting is global, add to watch list if global setting is watch
- global_setting.each do |user_id|
- if user_ids_global_level_watch.include?(user_id)
- user_ids << user_id
- end
- end
-
- user_ids
+ user_ids + (global_setting & user_ids_global_level_watch)
end
# Build a list of user_ids based on group notification settings
def select_group_members_ids(group, project_members, global_setting, user_ids_global_level_watch)
uids = user_ids_notifiable_on(group, :watch)
- # Group setting is watch, add to user_ids list if user is not project member
- user_ids = []
- uids.each do |user_id|
- if project_members.exclude?(user_id)
- user_ids << user_id
- end
- end
-
# Group setting is global, add to user_ids list if global setting is watch
- global_setting.each do |user_id|
- if project_members.exclude?(user_id) && user_ids_global_level_watch.include?(user_id)
- user_ids << user_id
- end
- end
-
- user_ids
+ uids + (global_setting & user_ids_global_level_watch) - project_members
end
def user_ids_with_global_level_watch(ids)