Replace multiple projects.status <> ... conditions with projects.status IN (...) for optimizer-friendliness in Project.allowed_to_condition (#43214).

Patch by Go MAEDA (user:maeda).


git-svn-id: https://svn.redmine.org/redmine/trunk@23979 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2025-09-17 01:02:16 +00:00
parent 7d6224979f
commit be78fbb34c

View File

@@ -186,7 +186,7 @@ class Project < ApplicationRecord
perm = Redmine::AccessControl.permission(permission)
base_statement =
if perm && perm.read?
"#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED} AND #{Project.table_name}.status <> #{Project::STATUS_SCHEDULED_FOR_DELETION}"
"#{Project.table_name}.status IN (#{Project::STATUS_ACTIVE}, #{Project::STATUS_CLOSED})"
else
"#{Project.table_name}.status = #{Project::STATUS_ACTIVE}"
end