fixed 组织成员数取组织内成员和组织所有仓库成员组合
This commit is contained in:
parent
0e8a3ddb79
commit
d2663eb7b7
|
@ -4,17 +4,30 @@ class Organizations::OrganizationUsersController < Organizations::BaseController
|
||||||
before_action :check_user_can_edit_org, only: [:destroy]
|
before_action :check_user_can_edit_org, only: [:destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@organization_users = @organization.organization_users.includes(:user)
|
# @organization_users = @organization.organization_users.includes(:user)
|
||||||
|
# if params[:search].present?
|
||||||
|
# search = params[:search].to_s.downcase
|
||||||
|
# user_condition_users = User.like(search).to_sql
|
||||||
|
# team_condition_teams = User.joins(:teams).merge(@organization.teams.like(search)).to_sql
|
||||||
|
# users = User.from("( #{user_condition_users} UNION #{team_condition_teams }) AS users")
|
||||||
|
#
|
||||||
|
# @organization_users = @organization_users.where(user_id: users).distinct
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# @organization_users = kaminari_paginate(@organization_users)
|
||||||
|
|
||||||
|
organization_user_ids = @organization.organization_users.pluck(:user_id).uniq
|
||||||
|
project_member_user_ids = @organization.projects.joins(:members).pluck("members.user_id").uniq
|
||||||
|
users = User.where(id: organization_user_ids + project_member_user_ids)
|
||||||
if params[:search].present?
|
if params[:search].present?
|
||||||
search = params[:search].to_s.downcase
|
search = params[:search].to_s.downcase
|
||||||
user_condition_users = User.like(search).to_sql
|
user_condition_users = User.like(search).to_sql
|
||||||
team_condition_teams = User.joins(:teams).merge(@organization.teams.like(search)).to_sql
|
team_condition_teams = User.joins(:teams).merge(@organization.teams.like(search)).to_sql
|
||||||
users = User.from("( #{user_condition_users} UNION #{team_condition_teams }) AS users")
|
user_ids = User.from("( #{user_condition_users} UNION #{team_condition_teams }) AS users").pluck(:id)
|
||||||
|
|
||||||
@organization_users = @organization_users.where(user_id: users).distinct
|
users = users.where(id: user_ids)
|
||||||
end
|
end
|
||||||
|
@users = kaminari_paginate(users)
|
||||||
@organization_users = kaminari_paginate(@organization_users)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pm_check_user
|
def pm_check_user
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
json.id org_user.id
|
json.id user&.id
|
||||||
json.user do
|
json.user do
|
||||||
json.partial! "organizations/user_detail", user: org_user.user
|
json.partial! "organizations/user_detail", user: user
|
||||||
end
|
end
|
||||||
|
|
||||||
json.team_names org_user.teams.pluck(:nickname)
|
json.team_names user.teams.where("teams.organization_id=?", organization.id).pluck(:nickname)
|
||||||
json.created_at org_user.created_at.strftime("%Y-%m-%d")
|
json.created_at user.created_on.strftime("%Y-%m-%d")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
json.total_count @organization_users.total_count
|
json.total_count @users.total_count
|
||||||
json.organization_users @organization_users do |org_user|
|
json.organization_users @users do |user|
|
||||||
next if org_user.user.blank?
|
next if user.blank?
|
||||||
json.partial! "detail", org_user: org_user, organization: @organization
|
json.partial! "detail", user: user, organization: @organization
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue