diff --git a/config/routes.rb b/config/routes.rb index 92b142ca6..5d067883e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -214,7 +214,7 @@ Rails.application.routes.draw do # API # - authenticated :user, lambda { |user| user.administrateur_id } do + authenticated :user, lambda { |user| user.administrateur? } do mount GraphqlPlayground::Rails::Engine, at: "/graphql", graphql_path: "/api/v2/graphql" end diff --git a/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake b/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake index a96758e98..82f634f72 100644 --- a/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake +++ b/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake @@ -3,23 +3,33 @@ namespace :after_party do task drop_down_list_options_to_json: :environment do puts "Running deploy task 'drop_down_list_options_to_json'" - types_de_champ = TypeDeChamp.joins(:drop_down_list).where(type_champ: [ - TypeDeChamp.type_champs.fetch(:drop_down_list), - TypeDeChamp.type_champs.fetch(:multiple_drop_down_list), - TypeDeChamp.type_champs.fetch(:linked_drop_down_list) - ]) - progress = ProgressReport.new(types_de_champ.count) - types_de_champ.find_each do |type_de_champ| - type_de_champ.drop_down_list_value = type_de_champ.drop_down_list_value - if type_de_champ.save - type_de_champ.drop_down_list.destroy - end - progress.inc - end - progress.finish + begin + types_de_champ = TypeDeChamp.joins(:drop_down_list).where(type_champ: [ + TypeDeChamp.type_champs.fetch(:drop_down_list), + TypeDeChamp.type_champs.fetch(:multiple_drop_down_list), + TypeDeChamp.type_champs.fetch(:linked_drop_down_list) + ]) - # Update task as completed. If you remove the line below, the task will - # run with every deploy (or every time you call after_party:run). - AfterParty::TaskRecord.create version: '20200618121241' + progress = ProgressReport.new(types_de_champ.count) + + types_de_champ.find_each do |type_de_champ| + type_de_champ.drop_down_list_value = type_de_champ.drop_down_list_value + + if type_de_champ.save + type_de_champ.drop_down_list.destroy + end + + progress.inc + end + + progress.finish + rescue ActiveRecord::ConfigurationError => e + warn e.message + puts "Skip deploy task." + ensure + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200618121241' + end end end diff --git a/lib/tasks/deployment/20200625113026_migrate_revisions.rake b/lib/tasks/deployment/20200625113026_migrate_revisions.rake index ffa7c986b..d56ed4f7a 100644 --- a/lib/tasks/deployment/20200625113026_migrate_revisions.rake +++ b/lib/tasks/deployment/20200625113026_migrate_revisions.rake @@ -3,17 +3,23 @@ namespace :after_party do task migrate_revisions: :environment do puts "Running deploy task 'migrate_revisions'" - procedures = Procedure.with_discarded.where(draft_revision_id: nil) - progress = ProgressReport.new(procedures.count) + if defined?(TmpDossiersMigrateRevisionsJob) + procedures = Procedure.with_discarded.where(draft_revision_id: nil) + progress = ProgressReport.new(procedures.count) - puts "Processing procedures" - procedures.find_each do |procedure| - RevisionsMigration.add_revisions(procedure) - progress.inc + puts "Processing procedures" + + procedures.find_each do |procedure| + RevisionsMigration.add_revisions(procedure) + progress.inc + end + + progress.finish + + TmpDossiersMigrateRevisionsJob.perform_later([]) + else + puts "Skip deploy task." end - progress.finish - - TmpDossiersMigrateRevisionsJob.perform_later([]) # Update task as completed. If you remove the line below, the task will # run with every deploy (or every time you call after_party:run).