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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
1f225354
Commit
1f225354
authored
Jul 08, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cache for todos counter calling TodoService
parent
ec73abcd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+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
No files found.
CHANGELOG
View file @
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
View file @
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
View file @
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
View file @
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
...
...
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