diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index 0b60574c1..54bbb4ccb 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -63,7 +63,7 @@ module Administrateurs def new @procedure ||= Procedure.new(for_individual: true) - @existing_tags = get_existing_tags + @existing_tags = Procedure.tags end SIGNIFICANT_DOSSIERS_THRESHOLD = 30 @@ -403,11 +403,5 @@ module Administrateurs def cloned_from_library? params[:from_new_from_existing].present? end - - def get_existing_tags - unnest = Arel::Nodes::NamedFunction.new('UNNEST', [Procedure.arel_table[:tags]]) - query = Procedure.select(unnest.as('tags')).distinct.order('tags') - Procedure.connection.query(query.to_sql).flatten - end end end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 7499cc75a..847024a16 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -833,6 +833,12 @@ class Procedure < ApplicationRecord published_at || created_at end + def self.tags + unnest = Arel::Nodes::NamedFunction.new('UNNEST', [self.arel_table[:tags]]) + query = self.select(unnest.as('tags')).distinct.order('tags') + self.connection.query(query.to_sql).flatten + end + private def move_new_children_to_new_parent_coordinate(new_draft)