FIX: groups pagination was broken

This commit is contained in:
Régis Hanol
2020-01-16 23:57:34 +01:00
parent 0c4ac2a7bc
commit 7b83237261
2 changed files with 29 additions and 2 deletions

View File

@ -80,6 +80,9 @@ class GroupsController < ApplicationController
type_filters = type_filters - [:my, :owner]
end
# count the total before doing pagination
total = groups.count
page = params[:page].to_i
page_size = MobileDetection.mobile_device?(request.user_agent) ? 15 : 36
groups = groups.offset(page * page_size).limit(page_size)
@ -93,14 +96,14 @@ class GroupsController < ApplicationController
extras: {
type_filters: type_filters
},
total_rows_groups: groups.count,
total_rows_groups: total,
load_more_groups: groups_path(
page: page + 1,
type: type,
order: order,
asc: params[:asc],
filter: filter
),
)
)
end