Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
109ab1a5
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
109ab1a5
编写于
4月 01, 2014
作者:
M
Marin Jankovski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add comments, fix style, better names for notification methods.
上级
528a641e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
29 deletion
+40
-29
app/services/notification_service.rb
app/services/notification_service.rb
+40
-29
未找到文件。
app/services/notification_service.rb
浏览文件 @
109ab1a5
...
...
@@ -178,23 +178,21 @@ class NotificationService
# Get project users with WATCH notification level
def
project_watchers
(
project
)
project_members
=
project_notification_list
(
project
)
project_members
=
users_project_notification
(
project
)
project_global
=
project_notification_list
(
project
,
Notification
::
N_GLOBAL
)
group_global
=
group_notification_list
(
project
,
Notification
::
N_GLOBAL
)
global_watch
=
User
.
where
(
id:
[
project_global
,
group_global
].
flatten
.
uniq
,
notification_level:
Notification
::
N_WATCH
).
pluck
(
:id
)
users_with_project_level_global
=
users_project_notification
(
project
,
Notification
::
N_GLOBAL
)
users_with_group_level_global
=
users_group_notification
(
project
,
Notification
::
N_GLOBAL
)
users
=
users_with_global_level_watch
([
users_with_project_level_global
,
users_with_group_level_global
].
flatten
.
uniq
)
project_watch
=
watch_project
(
project
,
project_global
,
global_watch
)
group_watch
=
watch_group
(
project
,
project_members
,
group_global
,
global_watch
)
users_with_project_setting
=
select_users_project_setting
(
project
,
users_with_project_level_global
,
users
)
users_with_group_setting
=
select_users_group_setting
(
project
,
project_members
,
users_with_group_level_global
,
users
)
User
.
where
(
id:
project_watch
.
concat
(
group_watch
).
uniq
).
to_a
User
.
where
(
id:
users_with_project_setting
.
concat
(
users_with_group_setting
).
uniq
).
to_a
end
def
project_notification_list
(
project
,
notification_level
=
nil
)
def
users_project_notification
(
project
,
notification_level
=
nil
)
project_members
=
project
.
users_projects
if
notification_level
project_members
.
where
(
notification_level:
notification_level
).
pluck
(
:user_id
)
else
...
...
@@ -202,7 +200,7 @@ class NotificationService
end
end
def
group_notification_list
(
project
,
notification_level
)
def
users_group_notification
(
project
,
notification_level
)
if
project
.
group
project
.
group
.
users_groups
.
where
(
notification_level:
notification_level
).
pluck
(
:user_id
)
else
...
...
@@ -210,34 +208,47 @@ class NotificationService
end
end
def
watch_project
(
project
,
global_setting
,
watch_global
)
uids
=
project_notification_list
(
project
,
Notification
::
N_WATCH
)
def
users_with_global_level_watch
(
ids
)
User
.
where
(
id:
ids
,
notification_level:
Notification
::
N_WATCH
).
pluck
(
:id
)
end
# Build a list of users based on project notifcation settings
def
select_users_project_setting
(
project
,
global_setting
,
users_global_level_watch
)
users
=
users_project_notification
(
project
,
Notification
::
N_WATCH
)
global_setting
.
each
do
|
i
|
if
watch_global
.
include?
(
i
)
uids
<<
i
# If project setting is global, add to watch list if global setting is watch
global_setting
.
each
do
|
user_id
|
if
users_global_level_watch
.
include?
(
user_id
)
users
<<
user_id
end
end
uids
.
uniq
users
end
def
watch_group
(
project
,
project_members
,
global_setting
,
watch_global
)
uids
=
group_notification_list
(
project
,
Notification
::
N_WATCH
)
# Group setting is watch, add to watchers list user is not project member
watch
=
[]
uids
.
each
do
|
i
|
if
project_members
.
exclude?
(
i
)
watch
<<
i
# Build a list of users based on group notifcation settings
def
select_users_group_setting
(
project
,
project_members
,
global_setting
,
users_global_level_watch
)
uids
=
users_group_notification
(
project
,
Notification
::
N_WATCH
)
# Group setting is watch, add to users list if user is not project member
users
=
[]
uids
.
each
do
|
user_id
|
if
project_members
.
exclude?
(
user_id
)
users
<<
user_id
end
end
global_setting
.
each
do
|
i
|
if
project_members
.
exclude?
(
i
)
&&
watch_global
.
include?
(
i
)
watch
<<
i
# Group setting is global, add to users list if global setting is watch
global_setting
.
each
do
|
user_id
|
if
project_members
.
exclude?
(
user_id
)
&&
users_global_level_watch
.
include?
(
user_id
)
users
<<
user_id
end
end
watch
.
uniq
users
end
# Remove users with disabled notifications from array
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录