Commit 0f190487 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '330580-rename' into 'master'

Rename active_user to billable_users_count

See merge request gitlab-org/gitlab!62908
parents f80086d1 69b2be6b
......@@ -256,7 +256,7 @@ VlhHNXRhVmszTkV0SVEzcEpNMWRyZEVoRU4ydHINCmRIRnFRVTlCVUVVM1pV
SlRORE4xUjFaYVJGb3JlWGM5UFZ4dUlpd2lhWFlpt2lKV00yRnNVbk5RTjJk
Sg0KU1hNMGExaE9SVGR2V2pKQlBUMWNiaUo5DQo=',
max_historical_user_count: 10,
active_users: 6
billable_users_count: 6
}
</code></pre>
......
......@@ -4,7 +4,7 @@ module Gitlab
class SeatLinkData
include Gitlab::Utils::StrongMemoize
attr_reader :timestamp, :key, :max_users, :active_users
attr_reader :timestamp, :key, :max_users, :billable_users_count
delegate :to_json, to: :data
......@@ -12,12 +12,12 @@ module Gitlab
# are preferable, like for SyncSeatLinkWorker, to determine seat link data, and in others,
# like for SyncSeatLinkRequestWorker, the params are passed because the values from when
# the job was enqueued are necessary.
def initialize(timestamp: nil, key: default_key, max_users: nil, active_users: nil)
def initialize(timestamp: nil, key: default_key, max_users: nil, billable_users_count: nil)
@current_time = Time.current
@timestamp = timestamp || historical_data&.recorded_at || current_time
@key = key
@max_users = max_users || default_max_count
@active_users = active_users || default_active_count
@billable_users_count = billable_users_count || default_billable_users_count
end
def sync
......@@ -54,7 +54,7 @@ module Gitlab
date: timestamp.to_date.to_s,
license_key: key,
max_historical_user_count: max_users,
active_users: active_users
billable_users_count: billable_users_count
}
end
......@@ -78,7 +78,7 @@ module Gitlab
end
end
def default_active_count
def default_billable_users_count
historical_data&.active_user_count
end
end
......
......@@ -15,12 +15,12 @@ class SyncSeatLinkRequestWorker
RequestError = Class.new(StandardError)
def perform(timestamp, license_key, max_historical_user_count, active_users)
def perform(timestamp, license_key, max_historical_user_count, billable_users_count)
response = Gitlab::HTTP.post(
URI_PATH,
base_uri: EE::SUBSCRIPTIONS_URL,
headers: request_headers,
body: request_body(timestamp, license_key, max_historical_user_count, active_users)
body: request_body(timestamp, license_key, max_historical_user_count, billable_users_count)
)
if response.success?
......@@ -43,12 +43,12 @@ class SyncSeatLinkRequestWorker
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end
def request_body(timestamp, license_key, max_historical_user_count, active_users)
def request_body(timestamp, license_key, max_historical_user_count, billable_users_count)
Gitlab::SeatLinkData.new(
timestamp: Time.zone.parse(timestamp),
key: license_key,
max_users: max_historical_user_count,
active_users: active_users
billable_users_count: billable_users_count
).to_json
end
......
......@@ -19,7 +19,7 @@ class SyncSeatLinkWorker # rubocop:disable Scalability/IdempotentWorker
seat_link_data.timestamp.iso8601,
seat_link_data.key,
seat_link_data.max_users,
seat_link_data.active_users
seat_link_data.billable_users_count
)
end
......
......@@ -283,7 +283,7 @@ RSpec.describe 'Admin updates EE-only settings' do
it 'loads seat link payload on click', :js do
page.within('#js-seat-link-settings') do
expected_payload_content = /(?=.*"date")(?=.*"timestamp")(?=.*"license_key")(?=.*"max_historical_user_count")(?=.*"active_users")/m
expected_payload_content = /(?=.*"date")(?=.*"timestamp")(?=.*"license_key")(?=.*"max_historical_user_count")(?=.*"billable_users_count")/m
expect(page).not_to have_content expected_payload_content
......
......@@ -8,14 +8,14 @@ RSpec.describe Gitlab::SeatLinkData do
timestamp: timestamp,
key: key,
max_users: max_users,
active_users: active_users
billable_users_count: billable_users_count
)
end
let_it_be(:timestamp) { Time.iso8601('2020-03-22T06:09:18Z') }
let_it_be(:key) { 'key' }
let_it_be(:max_users) { 11 }
let_it_be(:active_users) { 5 }
let_it_be(:billable_users_count) { 5 }
describe '#initialize' do
let_it_be(:utc_time) { Time.utc(2020, 3, 12, 12, 00) }
......@@ -23,14 +23,14 @@ RSpec.describe Gitlab::SeatLinkData do
let_it_be(:current_license) { create_current_license(starts_at: license_start_date)}
let_it_be(:max_before_today) { 15 }
let_it_be(:yesterday_active_count) { 12 }
let_it_be(:today_active_count) { 20 }
let_it_be(:yesterday_billable_users_count) { 12 }
let_it_be(:today_billable_users_count) { 20 }
before_all do
create(:historical_data, recorded_at: license_start_date, active_user_count: 10)
create(:historical_data, recorded_at: license_start_date + 1.day, active_user_count: max_before_today)
create(:historical_data, recorded_at: utc_time - 1.day, active_user_count: yesterday_active_count)
create(:historical_data, recorded_at: utc_time, active_user_count: today_active_count)
create(:historical_data, recorded_at: utc_time - 1.day, active_user_count: yesterday_billable_users_count)
create(:historical_data, recorded_at: utc_time, active_user_count: today_billable_users_count)
end
around do |example|
......@@ -44,8 +44,8 @@ RSpec.describe Gitlab::SeatLinkData do
expect(subject).to have_attributes(
timestamp: eq(utc_time),
key: eq(current_license.data),
max_users: eq(today_active_count),
active_users: eq(today_active_count)
max_users: eq(today_billable_users_count),
billable_users_count: eq(today_billable_users_count)
)
end
end
......@@ -56,7 +56,7 @@ RSpec.describe Gitlab::SeatLinkData do
timestamp: eq(timestamp),
key: eq(key),
max_users: eq(max_users),
active_users: eq(active_users)
billable_users_count: eq(billable_users_count)
)
end
......@@ -68,7 +68,7 @@ RSpec.describe Gitlab::SeatLinkData do
timestamp: eq(utc_time - 1.day),
key: eq(current_license.data),
max_users: eq(max_before_today),
active_users: eq(yesterday_active_count)
billable_users_count: eq(yesterday_billable_users_count)
)
end
end
......@@ -86,7 +86,7 @@ RSpec.describe Gitlab::SeatLinkData do
date: timestamp.to_date.iso8601,
license_key: key,
max_historical_user_count: max_users,
active_users: active_users
billable_users_count: billable_users_count
}.to_json
)
end
......
......@@ -23,7 +23,7 @@ RSpec.describe SyncSeatLinkRequestWorker, type: :worker do
date: '2019-12-31',
license_key: '123',
max_historical_user_count: 5,
active_users: 4
billable_users_count: 4
}.to_json
)
end
......@@ -117,7 +117,7 @@ RSpec.describe SyncSeatLinkRequestWorker, type: :worker do
date: '2020-01-01',
license_key: '123',
max_historical_user_count: 5,
active_users: 4
billable_users_count: 4
}.to_json
)
end
......
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