add pagination
This commit is contained in:
parent
da7fb11b78
commit
5e4a5b727c
1 changed files with 2 additions and 3 deletions
|
@ -4,7 +4,7 @@ module DataTable
|
||||||
|
|
||||||
def apply_filter(user, params)
|
def apply_filter(user, params)
|
||||||
params = sanitize_params(params)
|
params = sanitize_params(params)
|
||||||
selection_to_json(user, params[:draw], user.transactions)
|
selection_to_json user, params, user.transactions
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -37,12 +37,11 @@ module DataTable
|
||||||
end
|
end
|
||||||
|
|
||||||
def selection_to_json(user, draw, selection)
|
def selection_to_json(user, draw, selection)
|
||||||
selection = selection.to_a
|
|
||||||
{
|
{
|
||||||
draw: draw,
|
draw: draw,
|
||||||
recordsTotal: user.transactions.count,
|
recordsTotal: user.transactions.count,
|
||||||
recordsFiltered: selection.count,
|
recordsFiltered: selection.count,
|
||||||
data: selection.map { |transaction| {
|
data: selection.offset(params[:start]).take(params[:length]).map { |transaction| {
|
||||||
time: transaction.created_at,
|
time: transaction.created_at,
|
||||||
amount: transaction.signed_amount_for(user),
|
amount: transaction.signed_amount_for(user),
|
||||||
peer: transaction.peer_of(user).try(:name),
|
peer: transaction.peer_of(user).try(:name),
|
||||||
|
|
Loading…
Reference in a new issue