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

Use `select` instead of `pluck` to resolve unnecessary extra query

Aaron Contrerasde0920971996
diff --git a/app/models/project.rb b/app/models/project.rb
index 9a02ff88474..e29dd39e37c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -157,8 +157,8 @@ class Project < ApplicationRecord
scope :visible, ->(user = User.current) { where(id: Project.visible_by(user)) }
scope :newest, -> { order(created_at: :desc) }
scope :active, -> { where(active: true) }
- scope :with_member, ->(user = User.current) { where(id: user.memberships.pluck(:project_id)) }
- scope :without_member, ->(user = User.current) { where.not(id: user.memberships.pluck(:project_id)) }
+ scope :with_member, ->(user = User.current) { where(id: user.memberships.select(:project_id)) }
+ scope :without_member, ->(user = User.current) { where.not(id: user.memberships.select(:project_id)) }
scopes :activated_time_activity,
:visible_with_activated_time_activity