4/debian-10/plugins/easy_gantt/app/controllers/easy_gantt_controller.rb
# Load subproject of opened project which contains filtered tasks
#
# Project 1
# |-- Project 1.1
# |   `-- Project 1.1.1
# |       |-- Task 1
# |       `-- Task 2
# `-- Project 1.2
#
# If Project 1 is opened, Project 1.1 must be send even if there is no task
#
# TO_CONSIDER: Send full tree and load only opened_project's issues
#


If Project 1 is opened, Project 1.1 must be send even if there is no task

Send full tree and load only opened_project's issues
If Project 1 is opened Project 1 . 1 must be send even if there is no task Send full tree and load only opened_project ' s issues
def load_projects
      p_table = Project.table_name
      @projects = []
      if @project && @opened_project == @project
        @projects << @project
      end
      projects = @query.without_opened_project { |q|
          scope = q.create_entity_scope
          if @opened_project
            scope = scope.where("#{p_table}.lft >= ? AND #{p_table}.rgt <= ?", @opened_project.lft, @opened_project.rgt)
          end
          scope.distinct.pluck("#{p_table}.lft, #{p_table}.rgt, #{p_table}.parent_id")
        }
      if projects.blank?
        return
      end
      tree_conditions = []
      projects.each do |lft, rgt|
        tree_conditions << "(lft <= #{lft} AND rgt >= #{rgt})"
      end
      tree_conditions = tree_conditions.join(' OR ')
      @parent_ids = projects.map(&:last)
      @projects.concat Project.where(tree_conditions).where(parent_id: @opened_project.try(:id)).to_a
      Project.load_gantt_dates(@projects)
      if EasySetting.value(:easy_gantt_show_project_progress)
        Project.load_gantt_completed_percent(@projects)
      end
    end
def load_projects p_table = Project . table_name @projects = [ ] if @project && @opened_project == @project @projects << @project end projects = @query . without_opened_project { | q | scope = q . create_entity_scope if @opened_project scope = scope . where ( "#{p_table}.lft >= ? AND #{p_table}.rgt <= ?" , @opened_project . lft , @opened_project . rgt ) end scope . distinct . pluck ( "#{p_table}.lft, #{p_table}.rgt, #{p_table}.parent_id" ) } if projects . blank? return end tree_conditions = [ ] projects . each do | lft , rgt | tree_conditions << "(lft <= #{lft} AND rgt >= #{rgt})" end tree_conditions = tree_conditions . join ( ' OR ' ) @parent_ids = projects . map ( & :last ) @projects . concat Project . where ( tree_conditions ) . where ( parent_id : @opened_project . try ( :id ) ) . to_a Project . load_gantt_dates ( @projects ) if EasySetting . value ( :easy_gantt_show_project_progress ) Project . load_gantt_completed_percent ( @projects ) end end
Load subproject of opened project which contains filtered tasks
Project 1
|-- Project 1.1
|   `-- Project 1.1.1
|       |-- Task 1
|       `-- Task 2
`-- Project 1.2
Load subproject of opened project which contains filtered tasks Project 1 | -- Project 1 . 1 | ` -- Project 1 . 1 . 1 | | -- Task 1 | ` -- Task 2 ` -- Project 1 . 2
# Project gantt is opened, normally only subprojects will be sent # but there is not any root project yet # Not necessary, will take only subprojects # All ancestors conditions # From ancestors take only current opened level