POC: use Sidekiq.perform_bulk for Github repos (#16293)
This commit is contained in:
parent
4b4d8a7234
commit
67f68b1cc2
2 changed files with 4 additions and 5 deletions
|
|
@ -27,9 +27,8 @@ class GithubRepo < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.update_to_latest
|
||||
where("updated_at < ?", 26.hours.ago).ids.each do |repo_id|
|
||||
GithubRepos::RepoSyncWorker.perform_async(repo_id)
|
||||
end
|
||||
ids = where(updated_at: ...26.hours.ago).ids.map { |id| [id] }
|
||||
GithubRepos::RepoSyncWorker.perform_bulk(ids)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ RSpec.describe GithubRepo, type: :model do
|
|||
describe "::update_to_latest" do
|
||||
it "enqueues GithubRepos::RepoSyncWorker" do
|
||||
repo.update(updated_at: 1.week.ago)
|
||||
allow(GithubRepos::RepoSyncWorker).to receive(:perform_async)
|
||||
allow(GithubRepos::RepoSyncWorker).to receive(:perform_bulk)
|
||||
described_class.update_to_latest
|
||||
expect(GithubRepos::RepoSyncWorker).to have_received(:perform_async).with(repo.id)
|
||||
expect(GithubRepos::RepoSyncWorker).to have_received(:perform_bulk).with([[repo.id]])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue