Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
1f225354
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,体验更适合开发者的 AI 搜索 >>
提交
1f225354
编写于
7月 08, 2016
作者:
P
Paco Guzman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use cache for todos counter calling TodoService
上级
ec73abcd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
3 deletion
+16
-3
CHANGELOG
CHANGELOG
+1
-0
app/models/user.rb
app/models/user.rb
+2
-2
lib/api/todos.rb
lib/api/todos.rb
+1
-1
spec/requests/api/todos_spec.rb
spec/requests/api/todos_spec.rb
+12
-0
未找到文件。
CHANGELOG
浏览文件 @
1f225354
...
...
@@ -270,6 +270,7 @@ v 8.10.0
- Fix new snippet style bug (elliotec)
- Instrument Rinku usage
- Be explicit to define merge request discussion variables
- Use cache for todos counter calling TodoService
- Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
- RailsCache metris now includes fetch_hit/fetch_miss and read_hit/read_miss info.
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
...
...
app/models/user.rb
浏览文件 @
1f225354
...
...
@@ -809,13 +809,13 @@ class User < ActiveRecord::Base
def
todos_done_count
(
force:
false
)
Rails
.
cache
.
fetch
([
'users'
,
id
,
'todos_done_count'
],
force:
force
)
do
todos
.
don
e
.
count
TodosFinder
.
new
(
self
,
state: :done
).
execut
e
.
count
end
end
def
todos_pending_count
(
force:
false
)
Rails
.
cache
.
fetch
([
'users'
,
id
,
'todos_pending_count'
],
force:
force
)
do
todos
.
pending
.
count
TodosFinder
.
new
(
self
,
state: :pending
).
execute
.
count
end
end
...
...
lib/api/todos.rb
浏览文件 @
1f225354
...
...
@@ -73,7 +73,7 @@ module API
#
delete
do
todos
=
find_todos
todos
.
each
(
&
:done
)
TodoService
.
new
.
mark_todos_as_done
(
todos
,
current_user
)
todos
.
length
end
...
...
spec/requests/api/todos_spec.rb
浏览文件 @
1f225354
...
...
@@ -117,6 +117,12 @@ describe API::Todos, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
pending_1
.
reload
).
to
be_done
end
it
'updates todos cache'
do
expect_any_instance_of
(
User
).
to
receive
(
:update_todos_count_cache
).
and_call_original
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
,
john_doe
)
end
end
end
...
...
@@ -139,6 +145,12 @@ describe API::Todos, api: true do
expect
(
pending_2
.
reload
).
to
be_done
expect
(
pending_3
.
reload
).
to
be_done
end
it
'updates todos cache'
do
expect_any_instance_of
(
User
).
to
receive
(
:update_todos_count_cache
).
and_call_original
delete
api
(
"/todos"
,
john_doe
)
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录