Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-05-03 22:15:12 +0300
committerToon Claes <toon@gitlab.com>2018-05-07 10:42:09 +0300
commit3066de95f740df6a850c0ada2d0dd9a7cd5a097f (patch)
tree7c00790e7dbb375695d435e9496bf22773081c02 /app/workers
parent0bfc2b14c3de9a6ddb6470bd9a7002fb7fe9ffef (diff)
Rename methods to make it more clear what they do
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/repository_check/batch_worker.rb10
-rw-r--r--app/workers/repository_check/single_repository_worker.rb16
2 files changed, 14 insertions, 12 deletions
diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb
index 9aceb512d34..cfe81a489bf 100644
--- a/app/workers/repository_check/batch_worker.rb
+++ b/app/workers/repository_check/batch_worker.rb
@@ -16,7 +16,7 @@ module RepositoryCheck
# projects to check. By default sidekiq-cron will start a new
# RepositoryCheckWorker each hour so that as long as there are repositories to
# check, only one (or two) will be checked at a time.
- find_batch.each do |project_id|
+ project_ids.each do |project_id|
break if Time.now - start >= RUN_TIME
next unless try_obtain_lease(project_id)
@@ -32,7 +32,7 @@ module RepositoryCheck
# array of ID's. This is OK because we do it only once an hour, because
# getting ID's from Postgres is not terribly slow, and because no user
# has to sit and wait for this query to finish.
- def find_batch(batch_size = BATCH_SIZE)
+ def project_ids(batch_size = BATCH_SIZE)
project_ids = never_checked_project_ids(batch_size)
remaining_capacity = batch_size - project_ids.count
@@ -45,12 +45,14 @@ module RepositoryCheck
end
def never_checked_project_ids(batch_size)
- Project.where('last_repository_check_at IS NULL AND created_at < ?', 24.hours.ago)
+ Project.where(last_repository_check_at: nil)
+ .where('created_at < ?', 24.hours.ago)
.limit(batch_size).pluck(:id)
end
def old_checked_project_ids(batch_size)
- Project.where('last_repository_check_at < ?', 1.month.ago)
+ Project.where.not(last_repository_check_at: nil)
+ .where('last_repository_check_at < ?', 1.month.ago)
.reorder(last_repository_check_at: :asc)
.limit(batch_size).pluck(:id)
end
diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb
index 15912e05d48..3dcd4a97497 100644
--- a/app/workers/repository_check/single_repository_worker.rb
+++ b/app/workers/repository_check/single_repository_worker.rb
@@ -5,31 +5,31 @@ module RepositoryCheck
def perform(project_id)
project = Project.find(project_id)
- result = check(project)
+ healthy = project_healthy?(project)
- save_result(project, result)
+ update_repository_check_status(project, healthy)
end
private
- def save_result(project, result)
+ def update_repository_check_status(project, healthy)
project.update_columns(
- last_repository_check_failed: !result,
+ last_repository_check_failed: !healthy,
last_repository_check_at: Time.now
)
end
- def check(project)
- check_repo(project) && check_wiki_repo(project)
+ def project_healthy?(project)
+ repo_healthy?(project) && wiki_repo_healthy?(project)
end
- def check_repo(project)
+ def repo_healthy?(project)
return true if project.empty_repo?
git_fsck(project.repository)
end
- def check_wiki_repo(project)
+ def wiki_repo_healthy?(project)
return true unless project.wiki_enabled?
# Historically some projects never had their wiki repos initialized;