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
t.boolean "unique_ips_limit_enabled", default: false, null: false
t.decimal "polling_interval_multiplier", default: 1.0, null: false
t.boolean "usage_ping_enabled", default: true, null: false
t.string "uuid"
end
create_table "audit_events", force: :cascade do |t|
......
module Gitlab
class UsageData
include Gitlab::CurrentSettings
class << self
def data
Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data }
......@@ -45,7 +47,8 @@ module Gitlab
end
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,
recorded_at: Time.now,
mattermost_enabled: Gitlab.config.mattermost.enabled }
......
......@@ -12,9 +12,10 @@ describe Gitlab::UsageData do
expect(subject.keys).to match_array(%i(
active_user_count
counts
version
recorded_at
mattermost_enabled
version
uuid
))
end
......@@ -57,6 +58,7 @@ describe Gitlab::UsageData do
subject { Gitlab::UsageData.license_usage_data }
it "gathers license data" do
expect(subject[:uuid]).to eq(current_application_settings.uuid)
expect(subject[:version]).to eq(Gitlab::VERSION)
expect(subject[:active_user_count]).to eq(User.active.count)
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