Commit 880da96a authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'al-233444-show-last-enqueue-time-billing-page' into 'master'

Show when the last update to seats usage data was in the Billing page

See merge request gitlab-org/gitlab!42763
parents 62bb3e68 65ad2340
...@@ -71,6 +71,13 @@ module BillingPlansHelper ...@@ -71,6 +71,13 @@ module BillingPlansHelper
namespace == current_user.namespace namespace == current_user.namespace
end end
def seats_data_last_update_info
last_enqueue_time = UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.last_enqueue_time&.utc
return _("Seats usage data as of %{last_enqueue_time}" % { last_enqueue_time: last_enqueue_time }) if last_enqueue_time
_('Seats usage data is updated every day at 12:00pm UTC')
end
private private
def plan_purchase_url(group, plan) def plan_purchase_url(group, plan)
......
...@@ -12,3 +12,5 @@ ...@@ -12,3 +12,5 @@
- if namespace.actual_plan&.paid? - if namespace.actual_plan&.paid?
.center .center
&= s_('BillingPlans|If you would like to downgrade your plan please contact %{support_link_start}Customer Support%{support_link_end}.').html_safe % { support_link_start: support_link_start, support_link_end: support_link_end } &= s_('BillingPlans|If you would like to downgrade your plan please contact %{support_link_start}Customer Support%{support_link_end}.').html_safe % { support_link_start: support_link_start, support_link_end: support_link_end }
%p= seats_data_last_update_info
...@@ -39,6 +39,10 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker # rubocop:disable Scalab ...@@ -39,6 +39,10 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker # rubocop:disable Scalab
end end
end end
def self.last_enqueue_time
Sidekiq::Cron::Job.find('update_max_seats_used_for_gitlab_com_subscriptions_worker')&.last_enqueue_time
end
private private
def track_error(subscription) def track_error(subscription)
......
---
title: Show when the last update to seats usage data was in the Billing page
merge_request: 42763
author:
type: added
...@@ -125,4 +125,26 @@ RSpec.describe BillingPlansHelper do ...@@ -125,4 +125,26 @@ RSpec.describe BillingPlansHelper do
end end
end end
end end
describe '#seats_data_last_update_info' do
before do
allow(UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker).to receive(:last_enqueue_time).and_return(enqueue_time)
end
context 'when last_enqueue_time from the worker is known' do
let(:enqueue_time) { Time.current }
it 'shows the last enqueue time' do
expect(helper.seats_data_last_update_info).to match("as of #{enqueue_time}")
end
end
context 'when last_enqueue_time from the worker is unknown' do
let(:enqueue_time) { nil }
it 'shows default message' do
expect(helper.seats_data_last_update_info).to match('is updated every day at 12:00pm UTC')
end
end
end
end end
...@@ -120,4 +120,16 @@ RSpec.describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do ...@@ -120,4 +120,16 @@ RSpec.describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
end end
end end
end end
describe '.last_enqueue_time' do
it 'returns last_enqueue_time from the cron job instance' do
time = Time.current
job = double(Sidekiq::Cron::Job, last_enqueue_time: time)
allow(Sidekiq::Cron::Job).to receive(:find)
.with('update_max_seats_used_for_gitlab_com_subscriptions_worker')
.and_return(job)
expect(described_class.last_enqueue_time).to eq(time)
end
end
end end
...@@ -22439,6 +22439,12 @@ msgstr "" ...@@ -22439,6 +22439,12 @@ msgstr ""
msgid "Seat Link is disabled, and cannot be configured through this form." msgid "Seat Link is disabled, and cannot be configured through this form."
msgstr "" msgstr ""
msgid "Seats usage data as of %{last_enqueue_time}"
msgstr ""
msgid "Seats usage data is updated every day at 12:00pm UTC"
msgstr ""
msgid "Secondary" msgid "Secondary"
msgstr "" msgstr ""
......
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