Commit 69b2be6b authored by Mark Chao's avatar Mark Chao

Rename active_user to billable_users_count

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