Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
420ac06b
Commit
420ac06b
authored
Apr 29, 2021
by
David Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor notification recipients builder for watchers
Changelog: performance
parent
245ab858
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
app/services/notification_recipients/builder/base.rb
app/services/notification_recipients/builder/base.rb
+24
-0
changelogs/unreleased/326045-refactor-notification-recipients-builder-for-watch.yml
...45-refactor-notification-recipients-builder-for-watch.yml
+5
-0
No files found.
app/services/notification_recipients/builder/base.rb
View file @
420ac06b
...
...
@@ -172,6 +172,8 @@ module NotificationRecipients
# Get project users with WATCH notification level
# rubocop: disable CodeReuse/ActiveRecord
def
project_watchers
return
new_project_watchers
if
Feature
.
enabled?
(
:notification_setting_recipient_refactor
,
project
)
project_members_ids
=
user_ids_notifiable_on
(
project
)
user_ids_with_project_global
=
user_ids_notifiable_on
(
project
,
:global
)
...
...
@@ -184,16 +186,38 @@ module NotificationRecipients
user_scope
.
where
(
id:
user_ids_with_project_setting
.
concat
(
user_ids_with_group_setting
).
uniq
)
end
def
new_project_watchers
notification_by_sources
=
related_notification_settings_sources
(
:watch
)
return
if
notification_by_sources
.
blank?
user_ids
=
NotificationSetting
.
from_union
(
notification_by_sources
).
select
(
:user_id
)
user_scope
.
where
(
id:
user_ids
)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
group_watchers
return
new_group_watchers
if
Feature
.
enabled?
(
:notification_setting_recipient_refactor
,
project
)
user_ids_with_group_global
=
user_ids_notifiable_on
(
group
,
:global
)
user_ids
=
user_ids_with_global_level_watch
(
user_ids_with_group_global
)
user_ids_with_group_setting
=
select_group_members_ids
(
group
,
[],
user_ids_with_group_global
,
user_ids
)
user_scope
.
where
(
id:
user_ids_with_group_setting
)
end
def
new_group_watchers
return
[]
unless
group
user_ids
=
group
.
notification_settings
.
where
(
source_or_global_setting_by_level_query
(
:watch
)).
select
(
:user_id
)
user_scope
.
where
(
id:
user_ids
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
add_subscribed_users
...
...
changelogs/unreleased/326045-refactor-notification-recipients-builder-for-watch.yml
0 → 100644
View file @
420ac06b
---
title
:
Refactor notification recipients builder for watchers
merge_request
:
60572
author
:
type
:
performance
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment