summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-02-12 14:41:34 +0000
committerGitLab Release Tools Bot <robert+release-tools@gitlab.com>2019-02-12 16:33:23 +0000
commitbdc63ee179ecd6c9f2f5614ea2101c327e758159 (patch)
tree5c5027ab9f2fb09f4c7ebf4652be4f5aa4eb711d
parent27ed71e4642b518eb633b768899644cd1bef7679 (diff)
downloadgitlab-ce-bdc63ee179ecd6c9f2f5614ea2101c327e758159.tar.gz
Merge branch '7048_usage_ping_for_security_dashboard_as_default_view_for_groups-ce' into 'master'
Usage ping for Group overview default user preference See merge request gitlab-org/gitlab-ce!24980 (cherry picked from commit d29e81b2aa7fc26736eb09309bbbf2ab5a5d5050) 60bd0a24 Add user_preferences_usage to usage ping fa518963 Protect group overview usage ping w/ feature flag
-rw-r--r--lib/gitlab/usage_data.rb14
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb6
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 6bfcf83f388..a65f4a8639c 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -90,8 +90,14 @@ module Gitlab
todos: count(Todo),
uploads: count(Upload),
web_hooks: count(WebHook)
- }.merge(services_usage).merge(approximate_counts)
- }
+ }
+ .merge(services_usage)
+ .merge(approximate_counts)
+ }.tap do |data|
+ if Feature.enabled?(:group_overview_security_dashboard)
+ data[:counts][:user_preferences] = user_preferences_usage
+ end
+ end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -159,6 +165,10 @@ module Gitlab
}
end
+ def user_preferences_usage
+ {} # augmented in EE
+ end
+
def count(relation, fallback: -1)
relation.count
rescue ActiveRecord::StatementInvalid
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 4f5993ba226..d3eae80cc56 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -124,9 +124,15 @@ describe Gitlab::UsageData do
todos
uploads
web_hooks
+ user_preferences
))
end
+ it 'does not gather user preferences usage data when the feature is disabled' do
+ stub_feature_flags(group_overview_security_dashboard: false)
+ expect(subject[:counts].keys).not_to include(:user_preferences)
+ end
+
it 'gathers projects data correctly' do
count_data = subject[:counts]