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
43de46da
Commit
43de46da
authored
Aug 02, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
434e1c97
dd05aed1
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
9 additions
and
95 deletions
+9
-95
app/models/concerns/update_project_statistics.rb
app/models/concerns/update_project_statistics.rb
+1
-6
app/models/project_statistics.rb
app/models/project_statistics.rb
+0
-6
app/workers/namespaces/root_statistics_worker.rb
app/workers/namespaces/root_statistics_worker.rb
+1
-5
app/workers/namespaces/schedule_aggregation_worker.rb
app/workers/namespaces/schedule_aggregation_worker.rb
+1
-5
changelogs/unreleased/64092-removes-update-statistics-namespace-feature-flag.yml
...4092-removes-update-statistics-namespace-feature-flag.yml
+5
-0
spec/models/project_statistics_spec.rb
spec/models/project_statistics_spec.rb
+1
-12
spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
...mples/models/update_project_statistics_shared_examples.rb
+0
-40
spec/workers/namespaces/root_statistics_worker_spec.rb
spec/workers/namespaces/root_statistics_worker_spec.rb
+0
-11
spec/workers/namespaces/schedule_aggregation_worker_spec.rb
spec/workers/namespaces/schedule_aggregation_worker_spec.rb
+0
-10
No files found.
app/models/concerns/update_project_statistics.rb
View file @
43de46da
...
...
@@ -73,15 +73,10 @@ module UpdateProjectStatistics
def
schedule_namespace_aggregation_worker
run_after_commit
do
next
unless
schedule_aggregation_worker
?
next
if
project
.
nil
?
Namespaces
::
ScheduleAggregationWorker
.
perform_async
(
project
.
namespace_id
)
end
end
def
schedule_aggregation_worker?
!
project
.
nil?
&&
Feature
.
enabled?
(
:update_statistics_namespace
,
project
.
root_ancestor
)
end
end
end
app/models/project_statistics.rb
View file @
43de46da
...
...
@@ -93,15 +93,9 @@ class ProjectStatistics < ApplicationRecord
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_if_ee
(
'EE::ProjectStatistics'
)
app/workers/namespaces/root_statistics_worker.rb
View file @
43de46da
...
...
@@ -9,7 +9,7 @@ module Namespaces
def
perform
(
namespace_id
)
namespace
=
Namespace
.
find
(
namespace_id
)
return
unless
update_statistics_enabled_for?
(
namespace
)
&&
namespace
.
aggregation_scheduled?
return
unless
namespace
.
aggregation_scheduled?
Namespaces
::
StatisticsRefresherService
.
new
.
execute
(
namespace
)
...
...
@@ -23,9 +23,5 @@ module Namespaces
def
log_error
(
namespace_path
,
error_message
)
Gitlab
::
SidekiqLogger
.
error
(
"Namespace statistics can't be updated for
#{
namespace_path
}
:
#{
error_message
}
"
)
end
def
update_statistics_enabled_for?
(
namespace
)
Feature
.
enabled?
(
:update_statistics_namespace
,
namespace
)
end
end
end
app/workers/namespaces/schedule_aggregation_worker.rb
View file @
43de46da
...
...
@@ -12,7 +12,7 @@ module Namespaces
namespace
=
Namespace
.
find
(
namespace_id
)
root_ancestor
=
namespace
.
root_ancestor
return
unless
update_statistics_enabled_for?
(
root_ancestor
)
&&
!
root_ancestor
.
aggregation_scheduled?
return
if
root_ancestor
.
aggregation_scheduled?
Namespace
::
AggregationSchedule
.
safe_find_or_create_by!
(
namespace_id:
root_ancestor
.
id
)
rescue
ActiveRecord
::
RecordNotFound
...
...
@@ -37,9 +37,5 @@ module Namespaces
def
log_error
(
root_ancestor_id
)
Gitlab
::
SidekiqLogger
.
error
(
"Namespace can't be scheduled for aggregation:
#{
root_ancestor_id
}
does not exist"
)
end
def
update_statistics_enabled_for?
(
root_ancestor
)
Feature
.
enabled?
(
:update_statistics_namespace
,
root_ancestor
)
end
end
end
changelogs/unreleased/64092-removes-update-statistics-namespace-feature-flag.yml
0 → 100644
View file @
43de46da
---
title
:
Enables storage statistics for root namespaces on database
merge_request
:
31392
author
:
type
:
other
spec/models/project_statistics_spec.rb
View file @
43de46da
...
...
@@ -140,18 +140,7 @@ describe ProjectStatistics 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
context
'when arguments are passed'
do
it
'schedules the aggregation worker'
do
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
to
receive
(
:perform_async
)
...
...
spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
View file @
43de46da
...
...
@@ -32,19 +32,6 @@ shared_examples_for 'UpdateProjectStatistics' do
subject
.
save!
end
context
'when feature flag is disabled for the namespace'
do
it
'does not schedules a namespace statistics worker'
do
namespace
=
subject
.
project
.
root_ancestor
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
namespace
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
subject
.
save!
end
end
end
context
'when updating'
do
...
...
@@ -87,20 +74,6 @@ shared_examples_for 'UpdateProjectStatistics' do
subject
.
save!
end
.
not_to
exceed_query_limit
(
control_count
)
end
context
'when the feature flag is disabled for the namespace'
do
it
'does not schedule a namespace statistics worker'
do
namespace
=
subject
.
project
.
root_ancestor
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
namespace
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
subject
.
write_attribute
(
statistic_attribute
,
read_attribute
+
delta
)
subject
.
save!
end
end
end
context
'when destroying'
do
...
...
@@ -144,18 +117,5 @@ shared_examples_for 'UpdateProjectStatistics' do
project
.
destroy!
end
end
context
'when feature flag is disabled for the namespace'
do
it
'does not schedule a namespace statistics worker'
do
namespace
=
subject
.
project
.
root_ancestor
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
namespace
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
subject
.
destroy!
end
end
end
end
spec/workers/namespaces/root_statistics_worker_spec.rb
View file @
43de46da
...
...
@@ -74,15 +74,4 @@ describe Namespaces::RootStatisticsWorker, '#perform' do
worker
.
perform
(
group
.
id
)
end
end
context
'when update_statistics_namespace is off'
do
it
'does not create a new one'
do
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
group
)
expect_any_instance_of
(
Namespaces
::
StatisticsRefresherService
)
.
not_to
receive
(
:execute
)
worker
.
perform
(
group
.
id
)
end
end
end
spec/workers/namespaces/schedule_aggregation_worker_spec.rb
View file @
43de46da
...
...
@@ -31,16 +31,6 @@ describe Namespaces::ScheduleAggregationWorker, '#perform', :clean_gitlab_redis_
expect
(
group
.
aggregation_schedule
).
to
be_present
end
end
context
'when update_statistics_namespace is off'
do
it
'does not create a new one'
do
stub_feature_flags
(
update_statistics_namespace:
false
,
namespace:
group
)
expect
do
worker
.
perform
(
group
.
id
)
end
.
not_to
change
(
Namespace
::
AggregationSchedule
,
:count
)
end
end
end
context
'when group is not the root ancestor'
do
...
...
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