-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add config env vars to other pruning workers
- this also improves performance by limiting the date range of the pruning op
- Loading branch information
Showing
5 changed files
with
100 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'spec_helper' | ||
|
||
describe PruneRequestLogsWorker do | ||
let(:worker) { PruneRequestLogsWorker } | ||
let(:account) { create(:account) } | ||
|
||
# See: https://github.com/mhenrixon/sidekiq-unique-jobs#testing | ||
before do | ||
Sidekiq::Testing.inline! | ||
end | ||
|
||
after do | ||
Sidekiq::Worker.clear_all | ||
end | ||
|
||
it 'should prune backlog of request logs' do | ||
create_list(:request_log, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) | ||
create_list(:request_log, 50, account:) | ||
|
||
expect { worker.perform_async }.to( | ||
change { account.request_logs.count }.from(100).to(50), | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'spec_helper' | ||
|
||
describe PruneWebhookEventsWorker do | ||
let(:worker) { PruneWebhookEventsWorker } | ||
let(:account) { create(:account) } | ||
|
||
# See: https://github.com/mhenrixon/sidekiq-unique-jobs#testing | ||
before do | ||
Sidekiq::Testing.inline! | ||
end | ||
|
||
after do | ||
Sidekiq::Worker.clear_all | ||
end | ||
|
||
it 'should prune backlog of webhook events' do | ||
create_list(:webhook_event, 50, account:, created_at: (worker::BACKLOG_DAYS + 1).days.ago) | ||
create_list(:webhook_event, 50, account:) | ||
|
||
expect { worker.perform_async }.to( | ||
change { account.webhook_events.count }.from(100).to(50), | ||
) | ||
end | ||
end |