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
cd020401
Commit
cd020401
authored
Jul 02, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag namespace_snippets_size_stat
parent
85461b92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
app/models/project_statistics.rb
app/models/project_statistics.rb
+6
-1
spec/models/project_statistics_spec.rb
spec/models/project_statistics_spec.rb
+20
-0
No files found.
app/models/project_statistics.rb
View file @
cd020401
...
...
@@ -14,6 +14,7 @@ class ProjectStatistics < ApplicationRecord
COLUMNS_TO_REFRESH
=
[
:repository_size
,
:wiki_size
,
:lfs_objects_size
,
:commit_count
,
:snippets_size
].
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
FLAGGED_NAMESPACE_RELATABLE_COLUMNS
=
[
*
NAMESPACE_RELATABLE_COLUMNS
,
:snippets_size
].
freeze
scope
:for_project_ids
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
...
...
@@ -31,7 +32,7 @@ class ProjectStatistics < ApplicationRecord
end
end
if
only
.
empty?
||
only
.
any?
{
|
column
|
NAMESPACE_RELATABLE_COLUMNS
.
include?
(
column
)
}
if
only
.
empty?
||
only
.
any?
{
|
column
|
namespace_relatable_columns
.
include?
(
column
)
}
schedule_namespace_aggregation_worker
end
...
...
@@ -110,6 +111,10 @@ class ProjectStatistics < ApplicationRecord
Namespaces
::
ScheduleAggregationWorker
.
perform_async
(
project
.
namespace_id
)
end
end
def
namespace_relatable_columns
Feature
.
enabled?
(
:namespace_snippets_size_stat
)
?
FLAGGED_NAMESPACE_RELATABLE_COLUMNS
:
NAMESPACE_RELATABLE_COLUMNS
end
end
ProjectStatistics
.
prepend_if_ee
(
'EE::ProjectStatistics'
)
spec/models/project_statistics_spec.rb
View file @
cd020401
...
...
@@ -189,6 +189,26 @@ RSpec.describe ProjectStatistics do
statistics
.
refresh!
end
end
context
'when snippets_size is updated'
do
it
'schedules the aggregation worker'
do
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
to
receive
(
:perform_async
)
statistics
.
refresh!
(
only:
[
:snippets_size
])
end
context
'when feature flag :namespace_snippets_size_stat is disabled'
do
it
'does not schedules an aggregation worker'
do
stub_feature_flags
(
namespace_snippets_size_stat:
false
)
expect
(
Namespaces
::
ScheduleAggregationWorker
)
.
not_to
receive
(
:perform_async
)
statistics
.
refresh!
(
only:
[
:snippets_size
])
end
end
end
end
context
'when the column is not namespace relatable'
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