Skip to content

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

eager load attachments to avoid n+1

ulferts737fd6ec9170
diff --git a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
index 9e08109a486..75c034b7a7e 100644
--- a/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
+++ b/modules/ifc_models/app/controllers/ifc_models/ifc_models_controller.rb
@@ -34,17 +34,15 @@ module ::IFCModels
before_action :find_project_by_project_id, only: %i[index new create show show_defaults edit update destroy]
before_action :find_ifc_model_object, except: %i[index new create]
- before_action :find_all_ifc_models, only: %i[show show_defaults]
+ before_action :find_all_ifc_models, only: %i[show show_defaults index]
before_action :authorize
menu_item :ifc_models
def index
- @ifc_models = @project
- .ifc_models
- .order('created_at ASC')
- .includes(:uploader, :project)
+ @ifc_models = @ifc_models
+ .includes(:project, :uploader)
end
def new
@@ -116,6 +114,7 @@ module ::IFCModels
def find_all_ifc_models
@ifc_models = @project
.ifc_models
+ .includes(:attachments)
.order('created_at ASC')
end