-
Couldn't load subscription status.
- Fork 69
Closed
Description
Now that the user's query also fetches their membership and account, as shown below:
timeoverflow/app/controllers/users_controller.rb
Lines 8 to 14 in 6660a79
| @users = @search | |
| .result(distinct: false) | |
| .joins(members: :account) | |
| .eager_load(members: :account) | |
| .where(members: { organization: current_organization.id }) | |
| .page(params[:page]) | |
| .per(25) |
There's no point in fetching the memberships and building a Hash associating the user and his membership, as shown below:
timeoverflow/app/controllers/users_controller.rb
Lines 16 to 20 in 6660a79
| @memberships = current_organization.members. | |
| where(user_id: @users.map(&:id)). | |
| includes(:account).each_with_object({}) do |mem, ob| | |
| ob[mem.user_id] = mem | |
| end |
We already have that information. We simply need to access it directly from each of the user records returned by the first query.
Metadata
Metadata
Assignees
Labels
No labels