Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
dd406182
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,发现更多精彩内容 >>
提交
dd406182
编写于
8月 31, 2017
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'sidebar-cache-updates' into 'master'
Only update the sidebar count caches when needed See merge request !13878
上级
d5d24976
c158a22f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
0 deletion
+47
-0
app/models/issue.rb
app/models/issue.rb
+6
-0
app/models/merge_request.rb
app/models/merge_request.rb
+6
-0
changelogs/unreleased/sidebar-cache-updates.yml
changelogs/unreleased/sidebar-cache-updates.yml
+5
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+18
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+12
-0
未找到文件。
app/models/issue.rb
浏览文件 @
dd406182
...
...
@@ -269,7 +269,13 @@ class Issue < ActiveRecord::Base
end
end
def
update_project_counter_caches?
state_changed?
||
confidential_changed?
end
def
update_project_counter_caches
return
unless
update_project_counter_caches?
Projects
::
OpenIssuesCountService
.
new
(
project
).
refresh_cache
end
...
...
app/models/merge_request.rb
浏览文件 @
dd406182
...
...
@@ -942,7 +942,13 @@ class MergeRequest < ActiveRecord::Base
true
end
def
update_project_counter_caches?
state_changed?
end
def
update_project_counter_caches
return
unless
update_project_counter_caches?
Projects
::
OpenMergeRequestsCountService
.
new
(
target_project
).
refresh_cache
end
...
...
changelogs/unreleased/sidebar-cache-updates.yml
0 → 100644
浏览文件 @
dd406182
---
title
:
Only update the sidebar count caches when needed
merge_request
:
author
:
type
:
other
spec/models/issue_spec.rb
浏览文件 @
dd406182
...
...
@@ -769,4 +769,22 @@ describe Issue do
expect
(
described_class
.
public_only
).
to
eq
([
public_issue
])
end
end
describe
'#update_project_counter_caches?'
do
it
'returns true when the state changes'
do
subject
.
state
=
'closed'
expect
(
subject
.
update_project_counter_caches?
).
to
eq
(
true
)
end
it
'returns true when the confidential flag changes'
do
subject
.
confidential
=
true
expect
(
subject
.
update_project_counter_caches?
).
to
eq
(
true
)
end
it
'returns false when the state or confidential flag did not change'
do
expect
(
subject
.
update_project_counter_caches?
).
to
eq
(
false
)
end
end
end
spec/models/merge_request_spec.rb
浏览文件 @
dd406182
...
...
@@ -1700,4 +1700,16 @@ describe MergeRequest do
.
to
change
{
project
.
open_merge_requests_count
}.
from
(
1
).
to
(
0
)
end
end
describe
'#update_project_counter_caches?'
do
it
'returns true when the state changes'
do
subject
.
state
=
'closed'
expect
(
subject
.
update_project_counter_caches?
).
to
eq
(
true
)
end
it
'returns false when the state did not change'
do
expect
(
subject
.
update_project_counter_caches?
).
to
eq
(
false
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录