Refactor Geo::DesignRegistryFinder class

parent b22d6097
...@@ -3,24 +3,21 @@ ...@@ -3,24 +3,21 @@
module Geo module Geo
class DesignRegistryFinder < RegistryFinder class DesignRegistryFinder < RegistryFinder
def registry_count def registry_count
designs.count registry_class.count
end end
alias_method :count_registry, :registry_count
def count_synced def count_synced
registries.synced.count registry_class.synced.count
end end
def count_failed def count_failed
registries.failed.count registry_class.failed.count
end
def count_registry
registries.count
end end
def find_registry_differences(range) def find_registry_differences(range)
source_ids = designs.id_in(range).pluck_primary_key source_ids = replicables.id_in(range).pluck_primary_key
tracked_ids = registries.pluck_model_ids_in_range(range) tracked_ids = registry_class.pluck_model_ids_in_range(range)
untracked_ids = source_ids - tracked_ids untracked_ids = source_ids - tracked_ids
unused_tracked_ids = tracked_ids - source_ids unused_tracked_ids = tracked_ids - source_ids
...@@ -46,7 +43,7 @@ module Geo ...@@ -46,7 +43,7 @@ module Geo
# @param [Array<Integer>] except_ids ids that will be ignored from the query # @param [Array<Integer>] except_ids ids that will be ignored from the query
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_never_synced_registries(batch_size:, except_ids: []) def find_never_synced_registries(batch_size:, except_ids: [])
registries registry_class
.never_synced .never_synced
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.limit(batch_size) .limit(batch_size)
...@@ -55,7 +52,7 @@ module Geo ...@@ -55,7 +52,7 @@ module Geo
# rubocop:disable CodeReuse/ActiveRecord # rubocop:disable CodeReuse/ActiveRecord
def find_retryable_dirty_registries(batch_size:, except_ids: []) def find_retryable_dirty_registries(batch_size:, except_ids: [])
registries registry_class
.updated_recently .updated_recently
.model_id_not_in(except_ids) .model_id_not_in(except_ids)
.order(Gitlab::Database.nulls_first_order(:last_synced_at)) .order(Gitlab::Database.nulls_first_order(:last_synced_at))
...@@ -65,11 +62,11 @@ module Geo ...@@ -65,11 +62,11 @@ module Geo
private private
def designs def replicables
current_node.designs current_node.designs
end end
def registries def registry_class
Geo::DesignRegistry Geo::DesignRegistry
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment