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
Boxiang Sun
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
Show 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 @@
...
@@ -3,11 +3,10 @@
# because the service use maps to retrieve the project ids
# because the service use maps to retrieve the project ids
module
Projects
module
Projects
class
BatchOpenIssuesCountService
<
Projects
::
BatchCountService
class
BatchOpenIssuesCountService
<
Projects
::
BatchCountService
# Method not needed. Cache here is updated using
# overloaded OpenIssuesCount#refresh_cache method
def
global_count
def
global_count
nil
@global_count
||=
begin
count_service
.
query
(
project_ids
).
group
(
:project_id
).
count
end
end
end
def
count_service
def
count_service
...
...
app/services/projects/open_issues_count_service.rb
View file @
625957c2
...
@@ -40,9 +40,10 @@ module Projects
...
@@ -40,9 +40,10 @@ module Projects
cache_key
(
TOTAL_COUNT_KEY
)
cache_key
(
TOTAL_COUNT_KEY
)
end
end
# The block passed as parameter is ignored because we need to refresh both
# cache keys on every case.
def
refresh_cache
(
&
block
)
def
refresh_cache
(
&
block
)
if
block_given?
super
(
&
block
)
else
count_grouped_by_confidential
=
self
.
class
.
query
(
@project
,
public_only:
false
).
group
(
:confidential
).
count
count_grouped_by_confidential
=
self
.
class
.
query
(
@project
,
public_only:
false
).
group
(
:confidential
).
count
public_count
=
count_grouped_by_confidential
[
false
]
||
0
public_count
=
count_grouped_by_confidential
[
false
]
||
0
total_count
=
public_count
+
(
count_grouped_by_confidential
[
true
]
||
0
)
total_count
=
public_count
+
(
count_grouped_by_confidential
[
true
]
||
0
)
...
@@ -55,6 +56,7 @@ module Projects
...
@@ -55,6 +56,7 @@ module Projects
total_count
total_count
end
end
end
end
end
# We only show total issues count for reporters
# We only show total issues count for reporters
# which are allowed to view confidential issues
# which are allowed to view confidential issues
...
...
spec/services/projects/batch_open_issues_count_service_spec.rb
View file @
625957c2
...
@@ -19,8 +19,10 @@ describe Projects::BatchOpenIssuesCountService do
...
@@ -19,8 +19,10 @@ describe Projects::BatchOpenIssuesCountService do
it
'refreshes cache keys correctly'
do
it
'refreshes cache keys correctly'
do
subject
.
refresh_cache
subject
.
refresh_cache
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_1
))).
to
eq
(
2
)
# It does not update total issues cache
expect
(
Rails
.
cache
.
read
(
get_cache_key
(
subject
,
project_2
))).
to
eq
(
2
)
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
)
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
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