Commit c53afeda authored by Sean McGivern's avatar Sean McGivern Committed by Rémy Coutable

Port 'Add uuid to usage ping' to CE

CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1521
parent f5b42881
class AddUuidToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :application_settings, :uuid, :string
execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)}")
end
def down
remove_column :application_settings, :uuid
end
end
...@@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do ...@@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do
t.boolean "unique_ips_limit_enabled", default: false, null: false t.boolean "unique_ips_limit_enabled", default: false, null: false
t.decimal "polling_interval_multiplier", default: 1.0, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false
t.boolean "usage_ping_enabled", default: true, null: false t.boolean "usage_ping_enabled", default: true, null: false
t.string "uuid"
end end
create_table "audit_events", force: :cascade do |t| create_table "audit_events", force: :cascade do |t|
......
module Gitlab module Gitlab
class UsageData class UsageData
include Gitlab::CurrentSettings
class << self class << self
def data def data
Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data } Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data }
...@@ -45,7 +47,8 @@ module Gitlab ...@@ -45,7 +47,8 @@ module Gitlab
end end
def license_usage_data def license_usage_data
usage_data = { version: Gitlab::VERSION, usage_data = { uuid: current_application_settings.uuid,
version: Gitlab::VERSION,
active_user_count: User.active.count, active_user_count: User.active.count,
recorded_at: Time.now, recorded_at: Time.now,
mattermost_enabled: Gitlab.config.mattermost.enabled } mattermost_enabled: Gitlab.config.mattermost.enabled }
......
...@@ -12,9 +12,10 @@ describe Gitlab::UsageData do ...@@ -12,9 +12,10 @@ describe Gitlab::UsageData do
expect(subject.keys).to match_array(%i( expect(subject.keys).to match_array(%i(
active_user_count active_user_count
counts counts
version
recorded_at recorded_at
mattermost_enabled mattermost_enabled
version
uuid
)) ))
end end
...@@ -57,6 +58,7 @@ describe Gitlab::UsageData do ...@@ -57,6 +58,7 @@ describe Gitlab::UsageData do
subject { Gitlab::UsageData.license_usage_data } subject { Gitlab::UsageData.license_usage_data }
it "gathers license data" do it "gathers license data" do
expect(subject[:uuid]).to eq(current_application_settings.uuid)
expect(subject[:version]).to eq(Gitlab::VERSION) expect(subject[:version]).to eq(Gitlab::VERSION)
expect(subject[:active_user_count]).to eq(User.active.count) expect(subject[:active_user_count]).to eq(User.active.count)
expect(subject[:recorded_at]).to be_a(Time) expect(subject[:recorded_at]).to be_a(Time)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment