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
path: root/app
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-06-14 22:56:22 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-06-27 04:37:58 +0300
commitecbc409d88bb824aabaa89b8aa0164cd1750429f (patch)
tree2e2fe8788ae90b8675dd8964ae04597e8d48a045 /app
parentad8e7eb10e4106eab6ca2104ff1469e422fef445 (diff)
Perform Geo::RepositorySyncService for dirty projects
Diffstat (limited to 'app')
-rw-r--r--app/models/geo/project_registry.rb1
-rw-r--r--app/workers/geo_repository_sync_worker.rb16
2 files changed, 6 insertions, 11 deletions
diff --git a/app/models/geo/project_registry.rb b/app/models/geo/project_registry.rb
index 4c1692ba199..575bb813094 100644
--- a/app/models/geo/project_registry.rb
+++ b/app/models/geo/project_registry.rb
@@ -3,6 +3,7 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
validates :project, presence: true
+ scope :dirty, -> { where(arel_table[:resync_repository].eq(true).or(arel_table[:resync_wiki].eq(true))) }
scope :failed, -> { where.not(last_repository_synced_at: nil).where(last_repository_successful_sync_at: nil) }
scope :synced, -> { where.not(last_repository_synced_at: nil, last_repository_successful_sync_at: nil) }
end
diff --git a/app/workers/geo_repository_sync_worker.rb b/app/workers/geo_repository_sync_worker.rb
index 870b4238a2e..3ba0a225d50 100644
--- a/app/workers/geo_repository_sync_worker.rb
+++ b/app/workers/geo_repository_sync_worker.rb
@@ -12,7 +12,7 @@ class GeoRepositorySyncWorker
start_time = Time.now
project_ids_not_synced = find_project_ids_not_synced
- project_ids_updated_recently = find_synced_project_ids_updated_recently
+ project_ids_updated_recently = find_project_ids_updated_recently
project_ids = interleave(project_ids_not_synced, project_ids_updated_recently)
logger.info "Started Geo repository syncing for #{project_ids.length} project(s)"
@@ -43,24 +43,18 @@ class GeoRepositorySyncWorker
def find_project_ids_not_synced
Project.where.not(id: Geo::ProjectRegistry.synced.pluck(:project_id))
+ .order(last_repository_updated_at: :desc)
.limit(BATCH_SIZE)
.pluck(:id)
end
- def find_synced_project_ids_updated_recently
- Geo::ProjectRegistry.where(project_id: find_project_ids_updated_recently)
- .where('last_repository_synced_at <= ?', LAST_SYNC_INTERVAL.ago)
- .order(last_repository_synced_at: :asc)
+ def find_project_ids_updated_recently
+ Geo::ProjectRegistry.dirty
+ .order(Gitlab::Database.nulls_first_order(:last_repository_synced_at, :desc))
.limit(BATCH_SIZE)
.pluck(:project_id)
end
- def find_project_ids_updated_recently
- Project.where(id: Geo::ProjectRegistry.synced.pluck(:project_id))
- .where('last_repository_updated_at >= ?', LAST_SYNC_INTERVAL.ago)
- .pluck(:id)
- end
-
def interleave(first, second)
if first.length >= second.length
first.zip(second)