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
c85f9c5b
Commit
c85f9c5b
authored
Nov 24, 2017
by
Francisco Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review comments applied
parent
7c7877b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
app/services/base_count_service.rb
app/services/base_count_service.rb
+4
-0
app/services/projects/batch_count_service.rb
app/services/projects/batch_count_service.rb
+6
-2
lib/api/groups.rb
lib/api/groups.rb
+2
-2
No files found.
app/services/base_count_service.rb
View file @
c85f9c5b
...
@@ -12,6 +12,10 @@ class BaseCountService
...
@@ -12,6 +12,10 @@ class BaseCountService
Rails
.
cache
.
fetch
(
cache_key
,
cache_options
)
{
uncached_count
}.
to_i
Rails
.
cache
.
fetch
(
cache_key
,
cache_options
)
{
uncached_count
}.
to_i
end
end
def
count_stored?
Rails
.
cache
.
read
(
cache_key
).
present?
end
def
refresh_cache
(
&
block
)
def
refresh_cache
(
&
block
)
Rails
.
cache
.
write
(
cache_key
,
block_given?
?
yield
:
uncached_count
,
raw:
raw?
)
Rails
.
cache
.
write
(
cache_key
,
block_given?
?
yield
:
uncached_count
,
raw:
raw?
)
end
end
...
...
app/services/projects/batch_count_service.rb
View file @
c85f9c5b
...
@@ -12,7 +12,9 @@ module Projects
...
@@ -12,7 +12,9 @@ module Projects
def
refresh_cache
def
refresh_cache
@projects
.
each
do
|
project
|
@projects
.
each
do
|
project
|
current_count_service
(
project
).
refresh_cache
{
global_count
[
project
.
id
].
to_i
}
unless
current_count_service
(
project
).
count_stored?
current_count_service
(
project
).
refresh_cache
{
global_count
[
project
.
id
].
to_i
}
end
end
end
end
end
...
@@ -20,8 +22,10 @@ module Projects
...
@@ -20,8 +22,10 @@ module Projects
if
defined?
@service
if
defined?
@service
@service
.
project
=
project
@service
.
project
=
project
else
else
count_service
.
new
(
project
)
@service
=
count_service
.
new
(
project
)
end
end
@service
end
end
def
global_count
(
project
)
def
global_count
(
project
)
...
...
lib/api/groups.rb
View file @
c85f9c5b
...
@@ -64,8 +64,8 @@ module API
...
@@ -64,8 +64,8 @@ module API
forked_from_project:
[
:route
,
:forks
,
namespace: :route
,
tags: :taggings
])
forked_from_project:
[
:route
,
:forks
,
namespace: :route
,
tags: :taggings
])
projects
=
reorder_projects
(
projects
)
projects
=
reorder_projects
(
projects
)
projects
=
paginate
(
projects
)
projects
=
paginate
(
projects
)
projects_with_fork
=
projects
+
projects
.
map
(
&
:forked_from_project
).
compact
projects_with_fork
s
=
projects
+
projects
.
map
(
&
:forked_from_project
).
compact
::
Projects
::
BatchForksCountService
.
new
(
projects_with_fork
).
refresh_cache
::
Projects
::
BatchForksCountService
.
new
(
projects_with_fork
s
).
refresh_cache
::
Projects
::
BatchOpenIssuesCountService
.
new
(
projects
).
refresh_cache
::
Projects
::
BatchOpenIssuesCountService
.
new
(
projects
).
refresh_cache
projects
projects
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