Port 'Add uuid to usage ping' to CE
CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1521
This commit is contained in:
parent
f5b42881c8
commit
c53afeda0c
4 changed files with 24 additions and 2 deletions
|
@ -0,0 +1,16 @@
|
||||||
|
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.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|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue