models: add a Procedure#with_hidden scope, and remove unscoped usages

This avoids the broad use of `unscoped` to remove the `hidden_at`
clause.
This commit is contained in:
Pierre de La Morinerie 2020-01-28 16:41:15 +01:00
parent 4efea77280
commit 1448d5b098
7 changed files with 28 additions and 6 deletions

View file

@ -3,11 +3,11 @@ namespace :after_party do
task create_dummy_paths_for_archived_and_hidden_procedures: :environment do
rake_puts "Running deploy task 'create_dummy_paths_for_archived_procedures'"
Procedure.unscoped.archivees.where(path: nil).each do |p|
Procedure.with_hidden.archivees.where(path: nil).each do |p|
p.update_column(:path, SecureRandom.uuid)
end
Procedure.unscoped.hidden.where(path: nil).each do |p|
Procedure.hidden.where(path: nil).each do |p|
p.update_column(:path, SecureRandom.uuid)
end

View file

@ -2,7 +2,7 @@ namespace :after_party do
desc 'Deployment task: create_default_groupe_instructeur'
task create_default_groupe_instructeur: :environment do
Procedure
.unscoped
.with_hidden
.left_outer_joins(:groupe_instructeurs)
.where('groupe_instructeurs.id is null')
.find_each do |procedure|