Commit 7c79ae53 authored by Mike Kozono's avatar Mike Kozono Committed by Gabriel Mazetto
parent 8b4e6a70
......@@ -13,7 +13,7 @@ class AddVerificationIndexesToPackageFileRegistry < ActiveRecord::Migration[6.0]
def up
add_concurrent_index :package_file_registry, :verified_at, where: "(state = 2 AND verification_state = 0)", order: { verified_at: 'ASC NULLS FIRST' }, name: PENDING_VERIFICATION_INDEX_NAME
add_concurrent_index :package_file_registry, :verification_retry_at, where: "(state = 2 AND verification_state = 3)", order: { verification_retry_at: 'ASC NULLS FIRST' }, name: FAILED_VERIFICATION_INDEX_NAME
add_concurrent_index :package_file_registry, :verification_state, where: "(state = 2 AND (verification_state = 0 OR verification_state = 3))", name: NEEDS_VERIFICATION_INDEX_NAME
add_concurrent_index :package_file_registry, :verification_state, where: "(state = 2 AND (verification_state IN (0, 3)))", name: NEEDS_VERIFICATION_INDEX_NAME
end
def down
......
......@@ -125,7 +125,7 @@ ActiveRecord::Schema.define(version: 2020_12_08_031224) do
t.index ["retry_at"], name: "index_package_file_registry_on_retry_at"
t.index ["state"], name: "index_package_file_registry_on_state"
t.index ["verification_retry_at"], name: "package_file_registry_failed_verification", order: "NULLS FIRST", where: "((state = 2) AND (verification_state = 3))"
t.index ["verification_state"], name: "package_file_registry_needs_verification", where: "((state = 2) AND ((verification_state = 0) OR (verification_state = 3)))"
t.index ["verification_state"], name: "package_file_registry_needs_verification", where: "((state = 2) AND (verification_state = ANY (ARRAY[0, 3])))"
t.index ["verified_at"], name: "package_file_registry_pending_verification", order: "NULLS FIRST", where: "((state = 2) AND (verification_state = 0))"
end
......
......@@ -35,7 +35,7 @@ module Gitlab
scope :checksummed, -> { where.not(verification_checksum: nil) }
scope :not_checksummed, -> { where(verification_checksum: nil) }
scope :verification_timed_out, -> { verification_started.where("verification_started_at < ?", VERIFICATION_TIMEOUT.ago) }
scope :needs_verification, -> { verification_pending.or(verification_failed) }
scope :needs_verification, -> { with_verification_state(:verification_pending, :verification_failed) }
# rubocop:enable CodeReuse/ActiveRecord
state_machine :verification_state, initial: :verification_pending do
......
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