Commit 656c7f7b authored by Mike Kozono's avatar Mike Kozono

Simplify VerifiableRegistry scoping

The `VerifiableRegistry.available_verifiables` scope was meant to
invoke `synced`. And in that case, the overrides are unnecessary.
parent 17310da1
...@@ -18,21 +18,6 @@ module Geo ...@@ -18,21 +18,6 @@ module Geo
def verification_state_model_key def verification_state_model_key
self::MODEL_FOREIGN_KEY self::MODEL_FOREIGN_KEY
end 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 end
included do included do
...@@ -40,7 +25,7 @@ module Geo ...@@ -40,7 +25,7 @@ module Geo
sha_attribute :verification_checksum_mismatched sha_attribute :verification_checksum_mismatched
scope :available_verifiables, -> { all } scope :available_verifiables, -> { synced }
override :clear_verification_failure_fields! override :clear_verification_failure_fields!
def clear_verification_failure_fields! def clear_verification_failure_fields!
......
...@@ -178,7 +178,7 @@ module Geo ...@@ -178,7 +178,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden. # Bonus: This causes the progress bar to be hidden.
return unless verification_enabled? return unless verification_enabled?
registry_class.synced.verification_succeeded.count registry_class.verification_succeeded.count
end end
def verification_failed_count def verification_failed_count
...@@ -186,7 +186,7 @@ module Geo ...@@ -186,7 +186,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden. # Bonus: This causes the progress bar to be hidden.
return unless verification_enabled? return unless verification_enabled?
registry_class.synced.verification_failed.count registry_class.verification_failed.count
end end
def verification_total_count def verification_total_count
...@@ -194,7 +194,7 @@ module Geo ...@@ -194,7 +194,7 @@ module Geo
# Bonus: This causes the progress bar to be hidden. # Bonus: This causes the progress bar to be hidden.
return unless verification_enabled? return unless verification_enabled?
registry_class.synced.available_verifiables.count registry_class.available_verifiables.count
end end
end end
......
...@@ -114,40 +114,25 @@ module Gitlab ...@@ -114,40 +114,25 @@ module Gitlab
# query. # query.
# #
def verification_pending_batch(batch_size:) 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) start_verification_batch(relation)
end 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). # Returns IDs of records that failed to verify (calculate and save checksum).
# #
# Atomically marks those records "verification_started" in the same DB # Atomically marks those records "verification_started" in the same DB
# query. # query.
# #
def verification_failed_batch(batch_size:) 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) start_verification_batch(relation)
end 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 # @return [Integer] number of records that need verification
def needs_verification_count(limit:) def needs_verification_count(limit:)
needs_verification_relation.limit(limit).count # rubocop:disable CodeReuse/ActiveRecord needs_verification.limit(limit).count # rubocop:disable CodeReuse/ActiveRecord
end
# Overridden by Geo::VerifiableRegistry
def needs_verification_relation
needs_verification
end end
# @return [Integer] number of records that need reverification # @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