Patch #16905 » RM_16905_groups_index_users_count_optim.diff
app/views/groups/index.html.erb (copie de travail) | ||
---|---|---|
15 | 15 |
<% @groups.each do |group| %> |
16 | 16 |
<tr class="<%= cycle 'odd', 'even' %>"> |
17 | 17 |
<td><%= link_to h(group), edit_group_path(group) %></td> |
18 |
<td align="center"><%= group.users.size %></td>
|
|
18 |
<td align="center"><%= @group_users_count[group.id] || 0 %></td>
|
|
19 | 19 |
<td class="buttons"><%= delete_link group %></td> |
20 | 20 |
</tr> |
21 | 21 |
<% end %> |
app/controllers/groups_controller.rb (copie de travail) | ||
---|---|---|
26 | 26 | |
27 | 27 |
def index |
28 | 28 |
@groups = Group.sorted.all |
29 |
@group_users_count = User.joins(:groups).group('group_id').count |
|
29 | 30 | |
30 | 31 |
respond_to do |format| |
31 | 32 |
format.html |