Actions
Feature #42671
closedAvoid unnecessary SQL query for subprojects in ProjectsController#show when project has no children
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Description
The ProjectsController#show
action always queries for subprojects using @project.children.visible.to_a
, even when the current project is a leaf and has no subprojects.
Project Load (0.2ms) SELECT "projects".* FROM "projects" WHERE "projects"."parent_id" = ? AND (projects.status <> 9 AND projects.status <> 10) ORDER BY "projects"."lft" ASC [["parent_id", 5]] ↳ app/controllers/projects_controller.rb:179:in 'block (2 levels) in ProjectsController#show'
This patch adds a check using @project.leaf?
to skip the unnecessary query when the project has no children.
Files
Actions