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
[#58160] avoid expensive queries
Tobias Dillmannf3a8d06403d6
diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rbindex 80d6e445600..b6c2f49a432 100644--- a/app/components/projects/row_component.rb+++ b/app/components/projects/row_component.rb@@ -29,8 +29,9 @@#++module Projectsclass RowComponent < ::RowComponent- delegate :favored_project_ids, to: :tabledelegate :identifier, to: :project+ delegate :favored_project_ids, to: :table+ delegate :project_life_cycle_step_by_definition, to: :tabledef projectmodel.first@@ -99,13 +100,11 @@ module Projectsdef life_cycle_step_column(column)return nil unless user_can_view_project?- ls = Project::LifeCycleStep- .where(active: true)- .find_by(definition_id: column.life_cycle.id, project:)+ life_cycle_step = project_life_cycle_step_by_definition(column.life_cycle, project)- return nil if ls.blank?+ return nil if life_cycle_step.blank?- fmt_date_or_range(ls.start_date, ls.end_date)+ fmt_date_or_range(life_cycle_step.start_date, life_cycle_step.end_date)enddef created_atdiff --git a/app/components/projects/table_component.rb b/app/components/projects/table_component.rbindex 7958c81df2a..894bd45ab37 100644--- a/app/components/projects/table_component.rb+++ b/app/components/projects/table_component.rb@@ -195,6 +195,14 @@ module Projects@favored_project_ids ||= Favorite.where(user: current_user, favored_type: "Project").pluck(:favored_id)end+ def project_life_cycle_step_by_definition(definition, project)+ @project_life_cycle_steps_by_definition ||= Project::LifeCycleStep+ .where(active: true)+ .group_by { |s| [s.definition_id, s.project_id] }++ @project_life_cycle_steps_by_definition[[definition.id, project.id]]&.first+ end+def sorted_by_lft?query.orders.first&.attribute == :lftend