app/controllers/taxa/names_controller.rb
# TODO - there's too much logic here. Consider a Classifications class to use as presenter.
there's too much logic here. Consider a Classifications class to use as presenter.
there ' s too much logic here . Consider a Classifications class to use as presenter .
def index
    session[:split_hierarchy_entry_id] = params[:split_hierarchy_entry_id] if params[:split_hierarchy_entry_id]
    params[:all] = 1 if session[:split_hierarchy_entry_id] && !session[:split_hierarchy_entry_id].blank?
    if params[:all]
      @hierarchy_entries = @taxon_concept.deep_published_sorted_hierarchy_entries
      @other_hierarchy_entries = []
    else 
      @hierarchy_entries = @taxon_concept.deep_published_browsable_hierarchy_entries
      @other_hierarchy_entries = @taxon_concept.deep_published_nonbrowsable_hierarchy_entries
    end
    HierarchyEntry.preload_associations(@hierarchy_entries,
      [ { hierarchy: [ { resource: :content_partner }, :dwc_resource ] }, :rank, :flat_ancestors ])
    HierarchyEntry.preload_associations((@hierarchy_entries + @hierarchy_entries.collect(&:flat_ancestors)).flatten, :name)
    @pending_moves = HierarchyEntryMove.pending.find_all_by_hierarchy_entry_id(@hierarchy_entries)
    @assistive_section_header = I18n.t(:assistive_names_classifications_header)
    common_names_count
    respond_to do |format|
      format.html { render action: 'classifications' }
      format.js {}
    end
  end
def index session [ :split_hierarchy_entry_id ] = params [ :split_hierarchy_entry_id ] if params [ :split_hierarchy_entry_id ] params [ :all ] = 1 if session [ :split_hierarchy_entry_id ] && ! session [ :split_hierarchy_entry_id ] . blank? if params [ :all ] @hierarchy_entries = @taxon_concept . deep_published_sorted_hierarchy_entries @other_hierarchy_entries = [ ] else @hierarchy_entries = @taxon_concept . deep_published_browsable_hierarchy_entries @other_hierarchy_entries = @taxon_concept . deep_published_nonbrowsable_hierarchy_entries end HierarchyEntry . preload_associations ( @hierarchy_entries , [ { hierarchy : [ { resource : :content_partner } , :dwc_resource ] } , :rank , :flat_ancestors ] ) HierarchyEntry . preload_associations ( ( @hierarchy_entries + @hierarchy_entries . collect ( & :flat_ancestors ) ) . flatten , :name ) @pending_moves = HierarchyEntryMove . pending . find_all_by_hierarchy_entry_id ( @hierarchy_entries ) @assistive_section_header = I18n . t ( :assistive_names_classifications_header ) common_names_count respond_to do | format | format . html { render action : 'classifications' } format . js { } end end
TODO - there's too much logic here.
TODO - there ' s too much logic here .
# preloading the names for the current nodes and their ancestors. Children and sublings will be loaded later in # the views which is more efficient as we can preload only the first $max_children of each, sorted by name. It # is not possible to get for example "the first 10 children, alphabetically, for these 15 entries". That must be # done for each entry individually # TODO - this reloads the WHOLE tab... we should probably break it down a bit.