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
ac9db2a4
Commit
ac9db2a4
authored
Jul 08, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
7b7d95df
8f9fbbeb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
6 deletions
+84
-6
app/assets/javascripts/boards/components/board_blank_state.vue
...ssets/javascripts/boards/components/board_blank_state.vue
+4
-4
app/models/project_statistics.rb
app/models/project_statistics.rb
+23
-2
spec/models/project_statistics_spec.rb
spec/models/project_statistics_spec.rb
+43
-0
spec/workers/project_cache_worker_spec.rb
spec/workers/project_cache_worker_spec.rb
+14
-0
No files found.
app/assets/javascripts/boards/components/board_blank_state.vue
View file @
ac9db2a4
...
...
@@ -61,7 +61,7 @@ export default {
<div
class=
"board-blank-state p-3"
>
<p>
{{
__
(
'
BoardBlankState|Add the following default lists to your Issue Board with one click:
'
)
s
__
(
'
BoardBlankState|Add the following default lists to your Issue Board with one click:
'
)
}}
</p>
<ul
class=
"list-unstyled board-blank-state-list"
>
...
...
@@ -76,7 +76,7 @@ export default {
</ul>
<p>
{{
__
(
s
__
(
'
BoardBlankState|Starting out with the default set of lists will get you right on the way to making the most of your board.
'
,
)
}}
...
...
@@ -86,10 +86,10 @@ export default {
type=
"button"
@
click.stop=
"addDefaultLists"
>
{{
__
(
'
BoardBlankState|Add default lists
'
)
}}
{{
s
__
(
'
BoardBlankState|Add default lists
'
)
}}
</button>
<button
class=
"btn btn-default btn-block"
type=
"button"
@
click.stop=
"clearBlankState"
>
{{
__
(
"
BoardBlankState|Nevermind, I'll use my own
"
)
}}
{{
s
__
(
"
BoardBlankState|Nevermind, I'll use my own
"
)
}}
</button>
</div>
</
template
>
app/models/project_statistics.rb
View file @
ac9db2a4
# frozen_string_literal: true
class
ProjectStatistics
<
ApplicationRecord
include
AfterCommitQueue
belongs_to
:project
belongs_to
:namespace
...
...
@@ -15,6 +17,7 @@ class ProjectStatistics < ApplicationRecord
COLUMNS_TO_REFRESH
=
[
:repository_size
,
:wiki_size
,
:lfs_objects_size
,
:commit_count
].
freeze
INCREMENTABLE_COLUMNS
=
{
build_artifacts_size:
%i[storage_size]
,
packages_size:
%i[storage_size]
}.
freeze
NAMESPACE_RELATABLE_COLUMNS
=
[
:repository_size
,
:wiki_size
,
:lfs_objects_size
].
freeze
scope
:for_project_ids
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
...
...
@@ -22,13 +25,17 @@ class ProjectStatistics < ApplicationRecord
repository_size
+
lfs_objects_size
end
def
refresh!
(
only:
nil
)
def
refresh!
(
only:
[]
)
COLUMNS_TO_REFRESH
.
each
do
|
column
,
generator
|
if
only
.
blank
?
||
only
.
include?
(
column
)
if
only
.
empty
?
||
only
.
include?
(
column
)
public_send
(
"update_
#{
column
}
"
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
if
only
.
empty?
||
only
.
any?
{
|
column
|
NAMESPACE_RELATABLE_COLUMNS
.
include?
(
column
)
}
schedule_namespace_aggregation_worker
end
save!
end
...
...
@@ -81,6 +88,20 @@ class ProjectStatistics < ApplicationRecord
update_all
(
updates
.
join
(
', '
))
end
private
def
schedule_namespace_aggregation_worker
run_after_commit
do
next
unless
schedule_aggregation_worker?
Namespaces
::
ScheduleAggregationWorker
.
perform_async
(
project
.
namespace_id
)
end
end
def
schedule_aggregation_worker?
Feature
.
enabled?
(
:update_statistics_namespace
,
project
&
.
root_ancestor
)
end
end
ProjectStatistics
.
prepend
(
EE
::
ProjectStatistics
)
spec/models/project_statistics_spec.rb
View file @
ac9db2a4
...
...
@@ -135,6 +135,49 @@ describe ProjectStatistics do
expect
(
statistics
.
wiki_size
).
to
eq
(
0
)
end
end
context
'when the column is namespace relatable'
do
let
(
:namespace
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
context
'when the feature flag is off'
do
it
'does not schedule the aggregation worker'
do
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
namespace
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
statistics
.
refresh!
(
only:
[
:lfs_objects_size
])
end
end
context
'when the feature flag is on'
do
it
'schedules the aggregation worker'
do
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
to
receive
(
:perform_async
)
statistics
.
refresh!
(
only:
[
:lfs_objects_size
])
end
end
context
'when no argument is passed'
do
it
'schedules the aggregation worker'
do
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
to
receive
(
:perform_async
)
statistics
.
refresh!
end
end
end
context
'when the column is not namespace relatable'
do
it
'does not schedules an aggregation worker'
do
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
statistics
.
refresh!
(
only:
[
:commit_count
])
end
end
end
describe
'#update_commit_count'
do
...
...
spec/workers/project_cache_worker_spec.rb
View file @
ac9db2a4
...
...
@@ -36,6 +36,11 @@ describe ProjectCacheWorker do
end
context
'with an existing project'
do
before
do
lease_key
=
"namespace:namespaces_root_statistics:
#{
project
.
namespace_id
}
"
stub_exclusive_lease_taken
(
lease_key
,
timeout:
Namespace
::
AggregationSchedule
::
DEFAULT_LEASE_TIMEOUT
)
end
it
'refreshes the method caches'
do
expect_any_instance_of
(
Repository
).
to
receive
(
:refresh_method_caches
)
.
with
(
%i(readme)
)
...
...
@@ -81,6 +86,10 @@ describe ProjectCacheWorker do
expect
(
UpdateProjectStatisticsWorker
).
not_to
receive
(
:perform_in
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
.
with
(
project
.
namespace_id
)
worker
.
update_statistics
(
project
,
statistics
)
end
end
...
...
@@ -98,6 +107,11 @@ describe ProjectCacheWorker do
.
with
(
lease_timeout
,
project
.
id
,
statistics
)
.
and_call_original
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
to
receive
(
:perform_async
)
.
with
(
project
.
namespace_id
)
.
twice
worker
.
update_statistics
(
project
,
statistics
)
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