diff --git a/app/models/github_repo.rb b/app/models/github_repo.rb index 6072762e0..d31e4c26c 100644 --- a/app/models/github_repo.rb +++ b/app/models/github_repo.rb @@ -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 diff --git a/spec/models/github_repo_spec.rb b/spec/models/github_repo_spec.rb index c69d4d7c4..d94d2cb37 100644 --- a/spec/models/github_repo_spec.rb +++ b/spec/models/github_repo_spec.rb @@ -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