diff options
author | Sean McGivern <sean@gitlab.com> | 2017-04-05 13:29:48 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 15:20:55 +0200 |
commit | 0483019e9800dc1b4ef4493890f815f047b7c04e (patch) | |
tree | 24430c787a2e69166ccd214cc1e15a489f32e9e9 /lib/gitlab | |
parent | ebd5e9b4549ebc80155a5a8f139efdb40b6f8b12 (diff) | |
download | gitlab-ce-0483019e9800dc1b4ef4493890f815f047b7c04e.tar.gz |
Port 'Add more usage data to EE ping' to CE
CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/735
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/usage_data.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb new file mode 100644 index 00000000000..234d8680545 --- /dev/null +++ b/lib/gitlab/usage_data.rb @@ -0,0 +1,57 @@ +module Gitlab + class UsageData + class << self + def data + Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data } + end + + def uncached_data + license_usage_data.merge(system_usage_data) + end + + def to_json + data.to_json + end + + def system_usage_data + { + counts: { + boards: Board.count, + ci_builds: ::Ci::Build.count, + ci_pipelines: ::Ci::Pipeline.count, + ci_runners: ::Ci::Runner.count, + ci_triggers: ::Ci::Trigger.count, + deploy_keys: DeployKey.count, + deployments: Deployment.count, + environments: Environment.count, + groups: Group.count, + issues: Issue.count, + keys: Key.count, + labels: Label.count, + lfs_objects: LfsObject.count, + merge_requests: MergeRequest.count, + milestones: Milestone.count, + notes: Note.count, + pushes: Event.code_push.count, + pages_domains: PagesDomain.count, + projects: Project.count, + protected_branches: ProtectedBranch.count, + releases: Release.count, + services: Service.where(active: true).count, + snippets: Snippet.count, + todos: Todo.count, + web_hooks: WebHook.count + } + } + end + + def license_usage_data + usage_data = { version: Gitlab::VERSION, + active_user_count: User.active.count, + recorded_at: Time.now } + + usage_data + end + end + end +end |