diff options
author | Phil Hughes <me@iamphill.com> | 2016-12-02 19:48:34 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-12-02 19:50:08 +0300 |
commit | cc66ec2b73d6fa581f5300957597615ed1b58c55 (patch) | |
tree | 39dfc83febf58e6d7bb1388925a96145fcaf55ce /app/controllers/projects/project_members_controller.rb | |
parent | 89c22ed5af490f250800030ee4342c185dbc5358 (diff) |
Fixed Ruby to be better for performance
Fixed controls not showing in groups which fixes tests
Diffstat (limited to 'app/controllers/projects/project_members_controller.rb')
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index ccf5ff35171..10bc75b4c5e 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -10,20 +10,20 @@ class Projects::ProjectMembersController < Projects::ApplicationController @project_members = @project.project_members @project_members = @project_members.non_invite unless can?(current_user, :admin_project, @project) - @group = @project.group + group = @project.group - if @group - @group_members = @group.group_members - @group_members = @group_members.non_invite unless can?(current_user, :admin_group, @group) + if group + group_members = group.group_members.where.not(user_id: @project_members.select(:user_id)) + group_members = group_members.non_invite unless can?(current_user, :admin_group, @group) end if params[:search].present? - users = @project.users.search(params[:search]).to_a - @project_members = @project_members.where(user_id: users) + user_ids = @project.users.search(params[:search]).select(:id) + @project_members = @project_members.where(user_id: user_ids) - if @group_members - users = @group.users.search(params[:search]).to_a - @group_members = @group_members.where(user_id: users) + if group_members + user_ids = group.users.search(params[:search]).select(:id) + group_members = group_members.where(user_id: user_ids) end @group_links = @project.project_group_links.where(group_id: @project.invited_groups.search(params[:search]).select(:id)) @@ -31,8 +31,8 @@ class Projects::ProjectMembersController < Projects::ApplicationController members_id = @project_members.pluck(:id) - if @group_members - members_id << @group_members.select{ |member| !@project_members.find_by(user_id: member.user_id) }.select(&:id) + if group_members + members_id << group_members.pluck(:id) end @project_members = Member.where(id: members_id.flatten).order(access_level: :desc).page(params[:page]) |