Skip to content

Geo: Refactor :with_verification_state scope to reduce duplication and improve maintainability

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

The :with_verification_state scope from the Geo models is confusing, as it uses .where(verification_arel_table[:verification_state].eq(verification_state_value(state)).

This hints that it could be abstracted back to the VerifiableModel class.

Furthermore, inside the Geo::VerificationState module, the VERIFICATION_STATE_VALUES constant and verification_state_value method are confusing too.

Proposal

  • Abstract the :with_verification_state scope outside of the individual ActiveRecord model classes;
  • Possibly use VERIFICATION_STATE_VALUES.fetch inside the verification_state_value method in Geo::VerificationState so we fail on invalid keys;

⚠️ All ActiveRecord models for Geo need to use external state table to be able to abstract the scope. This is therefore dependent on the completion of Org Mover - Move all verification details into ... (&16633)

Edited by 🤖 GitLab Bot 🤖