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 ...@@ -12,12 +12,12 @@ class SyncSeatLinkRequestWorker
RequestError = Class.new(StandardError) 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( 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(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? raise RequestError, request_error_message(response) unless response.success?
...@@ -25,11 +25,12 @@ class SyncSeatLinkRequestWorker ...@@ -25,11 +25,12 @@ class SyncSeatLinkRequestWorker
private 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, date: date,
license_key: license_key, 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 }.to_json
end end
......
...@@ -18,7 +18,8 @@ class SyncSeatLinkWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -18,7 +18,8 @@ class SyncSeatLinkWorker # rubocop:disable Scalability/IdempotentWorker
SyncSeatLinkRequestWorker.perform_async( SyncSeatLinkRequestWorker.perform_async(
report_date.to_s, report_date.to_s,
License.current.data, License.current.data,
max_historical_user_count max_historical_user_count,
HistoricalData.at(report_date)&.active_user_count
) )
end 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' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe SyncSeatLinkRequestWorker, type: :worker do describe SyncSeatLinkRequestWorker, type: :worker do
describe '#perform' do describe '#perform' do
subject do subject do
described_class.new.perform('2020-01-01', '123', 5) described_class.new.perform('2020-01-01', '123', 5, 4)
end end
let(:seat_link_url) { [EE::SUBSCRIPTIONS_URL, '/api/v1/seat_links'].join } let(:seat_link_url) { [EE::SUBSCRIPTIONS_URL, '/api/v1/seat_links'].join }
...@@ -20,7 +20,8 @@ describe SyncSeatLinkRequestWorker, type: :worker do ...@@ -20,7 +20,8 @@ describe SyncSeatLinkRequestWorker, type: :worker do
body: { body: {
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
}.to_json }.to_json
) )
end end
......
...@@ -22,6 +22,7 @@ describe SyncSeatLinkWorker, type: :worker do ...@@ -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-12'.to_date, active_user_count: 10)
HistoricalData.create!(date: '2020-02-13'.to_date, active_user_count: 15) 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-12'.to_date, active_user_count: 20)
HistoricalData.create!(date: '2020-03-15'.to_date, active_user_count: 25) HistoricalData.create!(date: '2020-03-15'.to_date, active_user_count: 25)
allow(SyncSeatLinkRequestWorker).to receive(:perform_async).and_return(true) allow(SyncSeatLinkRequestWorker).to receive(:perform_async).and_return(true)
...@@ -35,7 +36,8 @@ describe SyncSeatLinkWorker, type: :worker do ...@@ -35,7 +36,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with( .with(
'2020-03-11', '2020-03-11',
License.current.data, License.current.data,
15 15,
10
) )
end end
end end
...@@ -55,7 +57,8 @@ describe SyncSeatLinkWorker, type: :worker do ...@@ -55,7 +57,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with( .with(
'2020-03-11', '2020-03-11',
License.current.data, License.current.data,
15 15,
10
) )
end end
end end
...@@ -75,7 +78,8 @@ describe SyncSeatLinkWorker, type: :worker do ...@@ -75,7 +78,8 @@ describe SyncSeatLinkWorker, type: :worker do
.with( .with(
'2020-03-11', '2020-03-11',
License.current.data, License.current.data,
15 15,
10
) )
end end
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