Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
36a8cc3e
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,发现更多精彩内容 >>
提交
36a8cc3e
编写于
4月 19, 2017
作者:
V
Valery Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove helpers assigned_issuables_count and cached_assigned_issuables_count
上级
59a330f4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
25 addition
and
27 deletion
+25
-27
app/helpers/issuables_helper.rb
app/helpers/issuables_helper.rb
+2
-10
app/models/user.rb
app/models/user.rb
+3
-3
app/services/members/authorized_destroy_service.rb
app/services/members/authorized_destroy_service.rb
+1
-0
app/views/layouts/header/_default.html.haml
app/views/layouts/header/_default.html.haml
+2
-2
app/views/layouts/nav/_dashboard.html.haml
app/views/layouts/nav/_dashboard.html.haml
+2
-2
doc/user/permissions.md
doc/user/permissions.md
+1
-1
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+4
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+6
-4
spec/services/members/authorized_destroy_service_spec.rb
spec/services/members/authorized_destroy_service_spec.rb
+4
-4
未找到文件。
app/helpers/issuables_helper.rb
浏览文件 @
36a8cc3e
...
@@ -165,11 +165,8 @@ module IssuablesHelper
...
@@ -165,11 +165,8 @@ module IssuablesHelper
html
.
html_safe
html
.
html_safe
end
end
def
cached_assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
def
assigned_issuables_count
(
issuable_type
)
cache_key
=
hexdigest
([
'assigned_issuables_count'
,
assignee
.
id
,
issuable_type
,
state
].
join
(
'-'
))
current_user
.
public_send
(
"assigned_open_
#{
issuable_type
}
_count"
)
Rails
.
cache
.
fetch
(
cache_key
,
expires_in:
2
.
minutes
)
do
assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
end
end
end
def
issuable_filter_params
def
issuable_filter_params
...
@@ -192,11 +189,6 @@ module IssuablesHelper
...
@@ -192,11 +189,6 @@ module IssuablesHelper
private
private
def
assigned_issuables_count
(
assignee
,
issuable_type
,
state
)
params
=
{
assignee_id:
assignee
.
id
,
state:
state
}
Object
.
const_get
(
"
#{
issuable_type
.
to_s
.
camelize
}
Finder"
).
new
(
current_user
,
params
).
execute
.
count
end
def
sidebar_gutter_collapsed?
def
sidebar_gutter_collapsed?
cookies
[
:collapsed_gutter
]
==
'true'
cookies
[
:collapsed_gutter
]
==
'true'
end
end
...
...
app/models/user.rb
浏览文件 @
36a8cc3e
...
@@ -888,8 +888,8 @@ class User < ActiveRecord::Base
...
@@ -888,8 +888,8 @@ class User < ActiveRecord::Base
@global_notification_setting
@global_notification_setting
end
end
def
assigned_open_merge_request_count
(
force:
false
)
def
assigned_open_merge_request
s
_count
(
force:
false
)
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_merge_request_count'
],
force:
force
)
do
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_merge_request
s
_count'
],
force:
force
)
do
MergeRequestsFinder
.
new
(
self
,
assignee_id:
self
.
id
,
state:
'opened'
).
execute
.
count
MergeRequestsFinder
.
new
(
self
,
assignee_id:
self
.
id
,
state:
'opened'
).
execute
.
count
end
end
end
end
...
@@ -901,7 +901,7 @@ class User < ActiveRecord::Base
...
@@ -901,7 +901,7 @@ class User < ActiveRecord::Base
end
end
def
update_cache_counts
def
update_cache_counts
assigned_open_merge_request_count
(
force:
true
)
assigned_open_merge_request
s
_count
(
force:
true
)
assigned_open_issues_count
(
force:
true
)
assigned_open_issues_count
(
force:
true
)
end
end
...
...
app/services/members/authorized_destroy_service.rb
浏览文件 @
36a8cc3e
...
@@ -36,6 +36,7 @@ module Members
...
@@ -36,6 +36,7 @@ module Members
project
=
member
.
source
project
=
member
.
source
project
.
issues
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
project
.
issues
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
project
.
merge_requests
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
project
.
merge_requests
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
member
.
user
.
update_cache_counts
end
end
end
end
end
end
...
...
app/views/layouts/header/_default.html.haml
浏览文件 @
36a8cc3e
...
@@ -47,13 +47,13 @@
...
@@ -47,13 +47,13 @@
%li
%li
=
link_to
assigned_issues_dashboard_path
,
title:
'Issues'
,
aria:
{
label:
"Issues"
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
link_to
assigned_issues_dashboard_path
,
title:
'Issues'
,
aria:
{
label:
"Issues"
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
icon
(
'hashtag fw'
)
=
icon
(
'hashtag fw'
)
-
issues_count
=
cached_assigned_issuables_count
(
current_user
,
:issues
,
:opened
)
-
issues_count
=
assigned_issuables_count
(
:issues
)
%span
.badge.issues-count
{
class:
(
'hidden'
if
issues_count
.
zero?
)
}
%span
.badge.issues-count
{
class:
(
'hidden'
if
issues_count
.
zero?
)
}
=
number_with_delimiter
(
issues_count
)
=
number_with_delimiter
(
issues_count
)
%li
%li
=
link_to
assigned_mrs_dashboard_path
,
title:
'Merge requests'
,
aria:
{
label:
"Merge requests"
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
link_to
assigned_mrs_dashboard_path
,
title:
'Merge requests'
,
aria:
{
label:
"Merge requests"
},
data:
{
toggle:
'tooltip'
,
placement:
'bottom'
,
container:
'body'
}
do
=
custom_icon
(
'mr_bold'
)
=
custom_icon
(
'mr_bold'
)
-
merge_requests_count
=
cached_assigned_issuables_count
(
current_user
,
:merge_requests
,
:opened
)
-
merge_requests_count
=
assigned_issuables_count
(
:merge_requests
)
%span
.badge.merge-requests-count
{
class:
(
'hidden'
if
merge_requests_count
.
zero?
)
}
%span
.badge.merge-requests-count
{
class:
(
'hidden'
if
merge_requests_count
.
zero?
)
}
=
number_with_delimiter
(
merge_requests_count
)
=
number_with_delimiter
(
merge_requests_count
)
%li
%li
...
...
app/views/layouts/nav/_dashboard.html.haml
浏览文件 @
36a8cc3e
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
I
I
%span
%span
Issues
Issues
.badge
=
number_with_delimiter
(
cached_assigned_issuables_count
(
current_user
,
:issues
,
:opened
))
.badge
=
number_with_delimiter
(
assigned_issuables_count
(
:issues
))
=
nav_link
(
path:
'dashboard#merge_requests'
)
do
=
nav_link
(
path:
'dashboard#merge_requests'
)
do
=
link_to
assigned_mrs_dashboard_path
,
title:
'Merge Requests'
,
class:
'dashboard-shortcuts-merge_requests'
do
=
link_to
assigned_mrs_dashboard_path
,
title:
'Merge Requests'
,
class:
'dashboard-shortcuts-merge_requests'
do
.shortcut-mappings
.shortcut-mappings
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
M
M
%span
%span
Merge Requests
Merge Requests
.badge
=
number_with_delimiter
(
cached_assigned_issuables_count
(
current_user
,
:merge_requests
,
:opened
))
.badge
=
number_with_delimiter
(
assigned_issuables_count
(
:merge_requests
))
=
nav_link
(
controller:
'dashboard/snippets'
)
do
=
nav_link
(
controller:
'dashboard/snippets'
)
do
=
link_to
dashboard_snippets_path
,
class:
'dashboard-shortcuts-snippets'
,
title:
'Snippets'
do
=
link_to
dashboard_snippets_path
,
class:
'dashboard-shortcuts-snippets'
,
title:
'Snippets'
do
.shortcut-mappings
.shortcut-mappings
...
...
doc/user/permissions.md
浏览文件 @
36a8cc3e
...
@@ -7,7 +7,7 @@ project itself, the highest permission level is used.
...
@@ -7,7 +7,7 @@ project itself, the highest permission level is used.
On public and internal projects the Guest role is not enforced. All users will
On public and internal projects the Guest role is not enforced. All users will
be able to create issues, leave comments, and pull or download the project code.
be able to create issues, leave comments, and pull or download the project code.
When member leaves the team the all assigned Issues and Merge Requests
When
a
member leaves the team the all assigned Issues and Merge Requests
will be unassigned automatically.
will be unassigned automatically.
GitLab administrators receive all permissions.
GitLab administrators receive all permissions.
...
...
spec/models/issue_spec.rb
浏览文件 @
36a8cc3e
...
@@ -361,7 +361,10 @@ describe Issue, models: true do
...
@@ -361,7 +361,10 @@ describe Issue, models: true do
it
'updates when assignees change'
do
it
'updates when assignees change'
do
user1
=
create
(
:user
)
user1
=
create
(
:user
)
user2
=
create
(
:user
)
user2
=
create
(
:user
)
issue
=
create
(
:issue
,
assignee:
user1
)
project
=
create
(
:empty_project
)
issue
=
create
(
:issue
,
assignee:
user1
,
project:
project
)
project
.
add_developer
(
user1
)
project
.
add_developer
(
user2
)
expect
(
user1
.
assigned_open_issues_count
).
to
eq
(
1
)
expect
(
user1
.
assigned_open_issues_count
).
to
eq
(
1
)
expect
(
user2
.
assigned_open_issues_count
).
to
eq
(
0
)
expect
(
user2
.
assigned_open_issues_count
).
to
eq
(
0
)
...
...
spec/models/merge_request_spec.rb
浏览文件 @
36a8cc3e
...
@@ -820,15 +820,17 @@ describe MergeRequest, models: true do
...
@@ -820,15 +820,17 @@ describe MergeRequest, models: true do
user1
=
create
(
:user
)
user1
=
create
(
:user
)
user2
=
create
(
:user
)
user2
=
create
(
:user
)
mr
=
create
(
:merge_request
,
assignee:
user1
)
mr
=
create
(
:merge_request
,
assignee:
user1
)
mr
.
project
.
add_developer
(
user1
)
mr
.
project
.
add_developer
(
user2
)
expect
(
user1
.
assigned_open_merge_request_count
).
to
eq
(
1
)
expect
(
user1
.
assigned_open_merge_request
s
_count
).
to
eq
(
1
)
expect
(
user2
.
assigned_open_merge_request_count
).
to
eq
(
0
)
expect
(
user2
.
assigned_open_merge_request
s
_count
).
to
eq
(
0
)
mr
.
assignee
=
user2
mr
.
assignee
=
user2
mr
.
save
mr
.
save
expect
(
user1
.
assigned_open_merge_request_count
).
to
eq
(
0
)
expect
(
user1
.
assigned_open_merge_request
s
_count
).
to
eq
(
0
)
expect
(
user2
.
assigned_open_merge_request_count
).
to
eq
(
1
)
expect
(
user2
.
assigned_open_merge_request
s
_count
).
to
eq
(
1
)
end
end
end
end
...
...
spec/services/members/authorized_destroy_service_spec.rb
浏览文件 @
36a8cc3e
...
@@ -21,8 +21,8 @@ describe Members::AuthorizedDestroyService, services: true do
...
@@ -21,8 +21,8 @@ describe Members::AuthorizedDestroyService, services: true do
member
=
group
.
members
.
find_by
(
user_id:
member_user
.
id
)
member
=
group
.
members
.
find_by
(
user_id:
member_user
.
id
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
4
).
to
(
2
)
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
4
).
to
(
2
)
expect
(
issue
.
reload
.
assignee_id
).
to
be_nil
expect
(
issue
.
reload
.
assignee_id
).
to
be_nil
expect
(
merge_request
.
reload
.
assignee_id
).
to
be_nil
expect
(
merge_request
.
reload
.
assignee_id
).
to
be_nil
...
@@ -38,8 +38,8 @@ describe Members::AuthorizedDestroyService, services: true do
...
@@ -38,8 +38,8 @@ describe Members::AuthorizedDestroyService, services: true do
member
=
project
.
members
.
find_by
(
user_id:
member_user
.
id
)
member
=
project
.
members
.
find_by
(
user_id:
member_user
.
id
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
2
).
to
(
0
)
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
2
).
to
(
0
)
end
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录