Commit 4020cbb8 authored by Fabio Pitino's avatar Fabio Pitino Committed by Stan Hu

Ensure namespace/project used minutes are reset

Do not rely on whether we have sent a notification
to the customre or not.

This solution may be less performant but ensures
we always reset the minutes for all namespaces.
parent c3aa5a68
......@@ -15,11 +15,13 @@ class ClearSharedRunnersMinutesWorker
.update_all("extra_shared_runners_minutes_limit = #{extra_minutes_left_sql} FROM namespace_statistics")
Namespace.with_ci_minutes_notification_sent.each_batch do |namespaces|
namespaces.update_all(last_ci_minutes_notification_at: nil, last_ci_minutes_usage_notification_level: nil)
end
Namespace.each_batch do |namespaces|
Namespace.transaction do
reset_statistics(NamespaceStatistics, namespaces)
reset_statistics(ProjectStatistics, namespaces)
namespaces.update_all(last_ci_minutes_notification_at: nil, last_ci_minutes_usage_notification_level: nil)
end
end
end
......
......@@ -4,7 +4,7 @@ describe ClearSharedRunnersMinutesWorker do
let(:worker) { described_class.new }
describe '#perform' do
let(:namespace) { create(:namespace, last_ci_minutes_notification_at: Time.now) }
let(:namespace) { create(:namespace) }
before do
expect_any_instance_of(described_class)
......
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