Commit 0ae6cb7e authored by James Lopez's avatar James Lopez

Merge branch 'send-active-users-in-seat-link' into 'master'

Send active users in seat link

See merge request gitlab-org/gitlab!27481
parents b2f799c3 894b88c8
......@@ -12,12 +12,12 @@ class SyncSeatLinkRequestWorker
RequestError = Class.new(StandardError)
def perform(date, license_key, max_historical_user_count)
def perform(date, license_key, max_historical_user_count, active_users)
response = Gitlab::HTTP.post(
URI_PATH,
base_uri: EE::SUBSCRIPTIONS_URL,
headers: request_headers,
body: request_body(date, license_key, max_historical_user_count)
body: request_body(date, license_key, max_historical_user_count, active_users)
)
raise RequestError, request_error_message(response) unless response.success?
......@@ -25,11 +25,12 @@ class SyncSeatLinkRequestWorker
private
def request_body(date, license_key, max_historical_user_count)
def request_body(date, license_key, max_historical_user_count, active_users)
{
date: date,
license_key: license_key,
max_historical_user_count: max_historical_user_count
max_historical_user_count: max_historical_user_count,
active_users: active_users
}.to_json
end
......
......@@ -18,7 +18,8 @@ class SyncSeatLinkWorker # rubocop:disable Scalability/IdempotentWorker
SyncSeatLinkRequestWorker.perform_async(
report_date.to_s,
License.current.data,
max_historical_user_count
max_historical_user_count,
HistoricalData.at(report_date)&.active_user_count
)
end
......
---
title: Send active users for each day in seat link POST request
merge_request: 27481
author:
type: changed
......@@ -5,7 +5,7 @@ require 'spec_helper'
describe SyncSeatLinkRequestWorker, type: :worker do
describe '#perform' do
subject do
described_class.new.perform('2020-01-01', '123', 5)
described_class.new.perform('2020-01-01', '123', 5, 4)
end
let(:seat_link_url) { [EE::SUBSCRIPTIONS_URL, '/api/v1/seat_links'].join }
......@@ -20,7 +20,8 @@ describe SyncSeatLinkRequestWorker, type: :worker do
body: {
date: '2020-01-01',
license_key: '123',
max_historical_user_count: 5
max_historical_user_count: 5,
active_users: 4
}.to_json
)
end
......
......@@ -22,6 +22,7 @@ describe SyncSeatLinkWorker, type: :worker do
HistoricalData.create!(date: '2020-02-12'.to_date, active_user_count: 10)
HistoricalData.create!(date: '2020-02-13'.to_date, active_user_count: 15)
HistoricalData.create!(date: '2020-03-11'.to_date, active_user_count: 10)
HistoricalData.create!(date: '2020-03-12'.to_date, active_user_count: 20)
HistoricalData.create!(date: '2020-03-15'.to_date, active_user_count: 25)
allow(SyncSeatLinkRequestWorker).to receive(:perform_async).and_return(true)
......@@ -35,7 +36,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with(
'2020-03-11',
License.current.data,
15
15,
10
)
end
end
......@@ -55,7 +57,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with(
'2020-03-11',
License.current.data,
15
15,
10
)
end
end
......@@ -75,7 +78,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with(
'2020-03-11',
License.current.data,
15
15,
10
)
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