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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
625957c2
Commit
625957c2
authored
Jun 22, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BatchOpenIssuesCount only updates public issues count
parent
4ab1011d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
app/services/projects/batch_open_issues_count_service.rb
app/services/projects/batch_open_issues_count_service.rb
+3
-4
app/services/projects/open_issues_count_service.rb
app/services/projects/open_issues_count_service.rb
+12
-10
spec/services/projects/batch_open_issues_count_service_spec.rb
...services/projects/batch_open_issues_count_service_spec.rb
+4
-2
No files found.
app/services/projects/batch_open_issues_count_service.rb
View file @
625957c2
...
...
@@ -3,11 +3,10 @@
# because the service use maps to retrieve the project ids
module
Projects
class
BatchOpenIssuesCountService
<
Projects
::
BatchCountService
# Method not needed. Cache here is updated using
# overloaded OpenIssuesCount#refresh_cache method
def
global_count
nil
@global_count
||=
begin
count_service
.
query
(
project_ids
).
group
(
:project_id
).
count
end
end
def
count_service
...
...
app/services/projects/open_issues_count_service.rb
View file @
625957c2
...
...
@@ -40,19 +40,21 @@ module Projects
cache_key
(
TOTAL_COUNT_KEY
)
end
# The block passed as parameter is ignored because we need to refresh both
# cache keys on every case.
def
refresh_cache
(
&
block
)
count_grouped_by_confidential
=
self
.
class
.
query
(
@project
,
public_only:
false
).
group
(
:confidential
).
count
public_count
=
count_grouped_by_confidential
[
false
]
||
0
total_count
=
public_count
+
(
count_grouped_by_confidential
[
true
]
||
0
)
if
block_given?
super
(
&
block
)
else
count_grouped_by_confidential
=
self
.
class
.
query
(
@project
,
public_only:
false
).
group
(
:confidential
).
count
public_count
=
count_grouped_by_confidential
[
false
]
||
0
total_count
=
public_count
+
(
count_grouped_by_confidential
[
true
]
||
0
)
update_cache_for_key
(
public_count_cache_key
)
do
public_count
end
update_cache_for_key
(
public_count_cache_key
)
do
public_count
end
update_cache_for_key
(
total_count_cache_key
)
do
total_count
update_cache_for_key
(
total_count_cache_key
)
do
total_count
end
end
end
...
...
spec/services/projects/batch_open_issues_count_service_spec.rb
View file @
625957c2
...
...
@@ -19,8 +19,10 @@ describe Projects::BatchOpenIssuesCountService do
it
'refreshes cache keys correctly'
do
subject
.
refresh_cache
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_1
))).
to
eq
(
2
)
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_2
))).
to
eq
(
2
)
# It does not update total issues cache
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_1
))).
to
eq
(
nil
)
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_2
))).
to
eq
(
nil
)
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_1
,
true
))).
to
eq
(
1
)
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_1
,
true
))).
to
eq
(
1
)
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