diff --git a/app/classes/query/location_base.rb b/app/classes/query/location_base.rb index 4d27d0ae86..aa0477f52d 100644 --- a/app/classes/query/location_base.rb +++ b/app/classes/query/location_base.rb @@ -30,7 +30,7 @@ def initialize_flavor add_ids_condition("locations") add_owner_and_time_stamp_conditions("locations") add_by_user_condition("locations") - add_by_editor_condition + add_by_editor_condition(:location) end add_bounding_box_conditions_for_locations add_pattern_condition @@ -39,19 +39,6 @@ def initialize_flavor super end - def add_by_editor_condition - return unless params[:by_editor] - - user = find_cached_parameter_instance(User, :by_editor) - @title_tag = :query_title_by_editor.t(type: :location, - user: user.legal_name) - @title_args[:user] = user.legal_name - version_table = :location_versions - add_join(version_table) - where << "#{version_table}.user_id = '#{user.id}'" - where << "locations.user_id != '#{user.id}'" - end - def add_pattern_condition return if params[:pattern].blank? diff --git a/app/classes/query/modules/conditions.rb b/app/classes/query/modules/conditions.rb index 2f93a32f30..68e910ae7a 100644 --- a/app/classes/query/modules/conditions.rb +++ b/app/classes/query/modules/conditions.rb @@ -21,6 +21,19 @@ def add_by_user_condition(table) where << "#{table}.user_id = '#{user.id}'" end + def add_by_editor_condition(type) + return unless params[:by_editor] + + user = find_cached_parameter_instance(User, :by_editor) + @title_tag = :query_title_by_editor + @title_args[:user] = user.legal_name + @title_args[:type] = type + version_table = :"#{type}_versions" + add_join(version_table) + where << "#{version_table}.user_id = '#{user.id}'" + where << "#{type}s.user_id != '#{user.id}'" + end + def add_pattern_condition return if params[:pattern].blank? diff --git a/app/classes/query/name_base.rb b/app/classes/query/name_base.rb index ab583cb311..cbc48f2df7 100644 --- a/app/classes/query/name_base.rb +++ b/app/classes/query/name_base.rb @@ -57,7 +57,7 @@ def initialize_flavor add_ids_condition("names") add_owner_and_time_stamp_conditions("names") add_by_user_condition("names") - add_by_editor_condition + add_by_editor_condition(:name) initialize_comments_and_notes_parameters initialize_name_parameters_for_name_queries add_pattern_condition @@ -71,19 +71,6 @@ def initialize_flavor super end - def add_by_editor_condition - return unless params[:by_editor] - - user = find_cached_parameter_instance(User, :by_editor) - @title_tag = :query_title_by_editor.t(type: :name, - user: user.legal_name) - @title_args[:user] = user.legal_name - version_table = :name_versions - add_join(version_table) - where << "#{version_table}.user_id = '#{user.id}'" - where << "names.user_id != '#{user.id}'" - end - def initialize_comments_and_notes_parameters add_boolean_condition( "LENGTH(COALESCE(names.notes,'')) > 0",