BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
base_count_service.rb
app/services/base_count_service.rb
+4
-0
batch_count_service.rb
app/services/projects/batch_count_service.rb
+6
-2
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
Rails
.
cache
.
fetch
(
cache_key
,
cache_options
)
{
uncached_count
}.
to_i
end
def
count_stored?
Rails
.
cache
.
read
(
cache_key
).
present?
end
def
refresh_cache
(
&
block
)
Rails
.
cache
.
write
(
cache_key
,
block_given?
?
yield
:
uncached_count
,
raw:
raw?
)
end
...
...
app/services/projects/batch_count_service.rb
View file @
c85f9c5b
...
...
@@ -12,7 +12,9 @@ module Projects
def
refresh_cache
@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
...
...
@@ -20,8 +22,10 @@ module Projects
if
defined?
@service
@service
.
project
=
project
else
count_service
.
new
(
project
)
@service
=
count_service
.
new
(
project
)
end
@service
end
def
global_count
(
project
)
...
...
lib/api/groups.rb
View file @
c85f9c5b
...
...
@@ -64,8 +64,8 @@ module API
forked_from_project:
[
:route
,
:forks
,
namespace: :route
,
tags: :taggings
])
projects
=
reorder_projects
(
projects
)
projects
=
paginate
(
projects
)
projects_with_fork
=
projects
+
projects
.
map
(
&
:forked_from_project
).
compact
::
Projects
::
BatchForksCountService
.
new
(
projects_with_fork
).
refresh_cache
projects_with_fork
s
=
projects
+
projects
.
map
(
&
:forked_from_project
).
compact
::
Projects
::
BatchForksCountService
.
new
(
projects_with_fork
s
).
refresh_cache
::
Projects
::
BatchOpenIssuesCountService
.
new
(
projects
).
refresh_cache
projects
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