Commit c9f831b4 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'mk/refactor-registry-verifiables-scope' into 'master'

Geo: Simplify VerifiableRegistry scoping

See merge request gitlab-org/gitlab!71682
parents adacec43 656c7f7b
......@@ -18,21 +18,6 @@ module Geo
def verification_state_model_key
self::MODEL_FOREIGN_KEY
end
override :verification_pending_batch_relation
def verification_pending_batch_relation(batch_size:)
super.synced
end
override :verification_failed_batch_relation
def verification_failed_batch_relation(batch_size:)
super.synced
end
override :needs_verification_relation
def needs_verification_relation
super.synced
end
end
included do
......@@ -40,7 +25,7 @@ module Geo
sha_attribute :verification_checksum_mismatched
scope :available_verifiables, -> { all }
scope :available_verifiables, -> { synced }
override :clear_verification_failure_fields!
def clear_verification_failure_fields!
......
......@@ -178,7 +178,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden.
return unless verification_enabled?
registry_class.synced.verification_succeeded.count
registry_class.verification_succeeded.count
end
def verification_failed_count
......@@ -186,7 +186,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden.
return unless verification_enabled?
registry_class.synced.verification_failed.count
registry_class.verification_failed.count
end
def verification_total_count
......@@ -194,7 +194,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden.
return unless verification_enabled?
registry_class.synced.available_verifiables.count
registry_class.available_verifiables.count
end
end
......
......@@ -114,40 +114,25 @@ module Gitlab
# query.
#
def verification_pending_batch(batch_size:)
relation = verification_pending_batch_relation(batch_size: batch_size)
relation = verification_pending.order(Gitlab::Database.nulls_first_order(:verified_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord
start_verification_batch(relation)
end
# Overridden by Geo::VerifiableRegistry
def verification_pending_batch_relation(batch_size:)
verification_pending.order(Gitlab::Database.nulls_first_order(:verified_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord
end
# Returns IDs of records that failed to verify (calculate and save checksum).
#
# Atomically marks those records "verification_started" in the same DB
# query.
#
def verification_failed_batch(batch_size:)
relation = verification_failed_batch_relation(batch_size: batch_size)
relation = verification_failed.verification_retry_due.order(Gitlab::Database.nulls_first_order(:verification_retry_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord
start_verification_batch(relation)
end
# Overridden by Geo::VerifiableRegistry
def verification_failed_batch_relation(batch_size:)
verification_failed.verification_retry_due.order(Gitlab::Database.nulls_first_order(:verification_retry_at)).limit(batch_size) # rubocop:disable CodeReuse/ActiveRecord
end
# @return [Integer] number of records that need verification
def needs_verification_count(limit:)
needs_verification_relation.limit(limit).count # rubocop:disable CodeReuse/ActiveRecord
end
# Overridden by Geo::VerifiableRegistry
def needs_verification_relation
needs_verification
needs_verification.limit(limit).count # rubocop:disable CodeReuse/ActiveRecord
end
# @return [Integer] number of records that need reverification
......
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