Project

General

Profile

Feature #42663 ยป optimize-gantt-rendering.patch

Go MAEDA, 2025-05-03 10:55

View differences:

lib/redmine/helpers/gantt.rb
198 198

  
199 199
      # Returns the distinct versions of the issues that belong to +project+
200 200
      def project_versions(project)
201
        project_issues(project).filter_map(&:fixed_version).uniq
201
        @project_versions ||= {}
202
        @project_versions[project&.id] ||= begin
203
          ids = project_issues(project).filter_map(&:fixed_version_id).uniq
204
          Version.where(id: ids).to_a
205
        end
202 206
      end
203 207

  
204 208
      # Returns the issues that belong to +project+ and are assigned to +version+
205 209
      def version_issues(project, version)
206
        project_issues(project).select {|issue| issue.fixed_version == version}
210
        @version_issues ||= {}
211
        @version_issues[[project&.id, version&.id]] ||=
212
          project_issues(project).select {|issue| issue.fixed_version_id == version&.id}
207 213
      end
208 214

  
209 215
      def render(options={})
......
232 238
        render_object_row(project, options)
233 239
        increment_indent(options) do
234 240
          # render issue that are not assigned to a version
235
          issues = project_issues(project).select {|i| i.fixed_version.nil?}
241
          issues = project_issues(project).select {|i| i.fixed_version_id.nil?}
236 242
          render_issues(issues, options)
237 243
          # then render project versions and their issues
238 244
          versions = project_versions(project)
......
778 784
          tag_options[:id] = "issue-#{object.id}"
779 785
          tag_options[:class] = "issue-subject hascontextmenu"
780 786
          tag_options[:title] = object.subject
781
          children = object.leaf? ? [] : object.children & project_issues(object.project)
782 787
          has_children =
783
            children.present? &&
784
              children.collect(&:fixed_version).uniq.intersect?([object.fixed_version])
788
            !object.leaf? &&
789
            object.children.any? do |child|
790
              child.fixed_version_id == object.fixed_version_id &&
791
              child.project_id == object.project_id
792
            end
785 793
        when Version
786 794
          tag_options[:id] = "version-#{object.id}"
787 795
          tag_options[:class] = "version-name"
    (1-1/1)