OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
extract methods from VersionsController
ulfertsda9e04b8927a
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rbindex 3f18652e3bb..0a268daf079 100644--- a/app/controllers/versions_controller.rb+++ b/app/controllers/versions_controller.rb@@ -43,29 +43,15 @@ class VersionsController < ApplicationController@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_work_packages? : (params[:with_subprojects].to_i == 1)project_ids = @with_subprojects ? @project.self_and_descendants.map(&:id) : [@project.id]- @versions = @project- .shared_versions+ @versions = find_versions(@with_subprojects, params[:completed])- if @with_subprojects- @versions = @versions.or(@project.rolled_up_versions)- end-- @versions = @versions.visible.order_by_semver_name.except(:distinct).uniq- @versions.reject! { |version| version.closed? || version.completed? } unless params[:completed]-- @issues_by_version = {}+ @wps_by_version = {}unless @selected_type_ids.empty?@versions.each do |version|- issues = version- .fixed_issues- .visible- .includes(:project, :status, :type, :priority)- .where(type_id: @selected_type_ids, project_id: project_ids)- .order("#{Project.table_name}.lft, #{::Type.table_name}.position, #{WorkPackage.table_name}.id")- @issues_by_version[version] = issues+ @wps_by_version[version] = work_packages_of_version(version, project_ids, @selected_type_ids)endend- @versions.reject! { |version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank? }+ @versions.reject! { |version| !project_ids.include?(version.project_id) && @wps_by_version[version].blank? }enddef show@@ -162,4 +148,25 @@ class VersionsController < ApplicationControllerrender action: failure_actionendend++ def find_versions(subprojects, completed)+ versions = @project.shared_versions++ if subprojects+ versions = versions.or(@project.rolled_up_versions)+ end++ versions = versions.visible.order_by_semver_name.except(:distinct).uniq+ versions.reject! { |version| version.closed? || version.completed? } unless completed+ versions+ end++ def work_packages_of_version(version, project_ids, selected_type_ids)+ version+ .fixed_issues+ .visible+ .includes(:project, :status, :type, :priority)+ .where(type_id: selected_type_ids, project_id: project_ids)+ .order("#{Project.table_name}.lft, #{::Type.table_name}.position, #{WorkPackage.table_name}.id")+ endenddiff --git a/app/views/versions/index.html.erb b/app/views/versions/index.html.erbindex 0cdffa30868..b91b4c0a8af 100644--- a/app/views/versions/index.html.erb+++ b/app/views/versions/index.html.erb@@ -49,7 +49,7 @@ See docs/COPYRIGHT.rdoc for more details.</h3><%= render partial: 'versions/overview', locals: {version: version} %><%= render(partial: "wiki/content", locals: {content: version.wiki_page.content}) if version.wiki_page %>- <% if (issues = @issues_by_version[version]) && issues.size > 0 %>+ <% if (issues = @wps_by_version[version]) && issues.size > 0 %><form><fieldset class="form--fieldset -collapsible"><legend class="form--fieldset-legend" ><%= l(:label_related_work_packages) %></legend>