summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/workers/repository_check/batch_worker.rb2
-rw-r--r--app/workers/repository_check/clear_worker.rb4
-rw-r--r--spec/workers/repository_check/batch_worker_spec.rb12
3 files changed, 9 insertions, 9 deletions
diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb
index 16cd77a9bf0..44b3145d50f 100644
--- a/app/workers/repository_check/batch_worker.rb
+++ b/app/workers/repository_check/batch_worker.rb
@@ -35,7 +35,7 @@ module RepositoryCheck
limit = 10_000
never_checked_projects = Project.where('last_repository_check_at IS NULL').limit(limit).
pluck(:id)
- old_check_projects = Project.where('last_repository_check_at < ?', 1.week.ago).
+ old_check_projects = Project.where('last_repository_check_at < ?', 1.month.ago).
reorder('last_repository_check_at ASC').limit(limit).pluck(:id)
never_checked_projects + old_check_projects
end
diff --git a/app/workers/repository_check/clear_worker.rb b/app/workers/repository_check/clear_worker.rb
index fe0cce9aab7..9c3347a7040 100644
--- a/app/workers/repository_check/clear_worker.rb
+++ b/app/workers/repository_check/clear_worker.rb
@@ -5,8 +5,8 @@ module RepositoryCheck
sidekiq_options retry: false
def perform
- # Do batched updates because these updates will be slow and locking
- Project.select(:id).find_in_batches(batch_size: 1000) do |batch|
+ # Do small batched updates because these updates will be slow and locking
+ Project.select(:id).find_in_batches(batch_size: 100) do |batch|
Project.where(id: batch.map(&:id)).update_all(
last_repository_check_failed: nil,
last_repository_check_at: nil,
diff --git a/spec/workers/repository_check/batch_worker_spec.rb b/spec/workers/repository_check/batch_worker_spec.rb
index 51caa645f47..f486e45ddad 100644
--- a/spec/workers/repository_check/batch_worker_spec.rb
+++ b/spec/workers/repository_check/batch_worker_spec.rb
@@ -5,17 +5,17 @@ describe RepositoryCheck::BatchWorker do
it 'prefers projects that have never been checked' do
projects = create_list(:project, 3)
- projects[0].update_column(:last_repository_check_at, 1.month.ago)
- projects[2].update_column(:last_repository_check_at, 3.weeks.ago)
+ projects[0].update_column(:last_repository_check_at, 4.months.ago)
+ projects[2].update_column(:last_repository_check_at, 3.months.ago)
expect(subject.perform).to eq(projects.values_at(1, 0, 2).map(&:id))
end
it 'sorts projects by last_repository_check_at' do
projects = create_list(:project, 3)
- projects[0].update_column(:last_repository_check_at, 2.weeks.ago)
- projects[1].update_column(:last_repository_check_at, 1.month.ago)
- projects[2].update_column(:last_repository_check_at, 3.weeks.ago)
+ projects[0].update_column(:last_repository_check_at, 2.months.ago)
+ projects[1].update_column(:last_repository_check_at, 4.months.ago)
+ projects[2].update_column(:last_repository_check_at, 3.months.ago)
expect(subject.perform).to eq(projects.values_at(1, 2, 0).map(&:id))
end
@@ -23,7 +23,7 @@ describe RepositoryCheck::BatchWorker do
it 'excludes projects that were checked recently' do
projects = create_list(:project, 3)
projects[0].update_column(:last_repository_check_at, 2.days.ago)
- projects[1].update_column(:last_repository_check_at, 1.month.ago)
+ projects[1].update_column(:last_repository_check_at, 2.months.ago)
projects[2].update_column(:last_repository_check_at, 3.days.ago)
expect(subject.perform).to eq([projects[1].id])