1 package CXGN
::BrAPI
::Pagination
;
6 sub pagination_response
{
8 my $data_count = shift;
12 $page_size += 0; # convert from string to int
13 $page += 0; # convert from string to int?
15 my $total_pages_decimal = $data_count/$page_size;
16 my $total_pages = ($total_pages_decimal == int $total_pages_decimal) ?
$total_pages_decimal : int($total_pages_decimal + 1);
17 my %pagination = (pageSize
=>$page_size, currentPage
=>$page, totalCount
=>$data_count, totalPages
=>$total_pages);
24 my $page_size = shift;
26 my $total_count = $data ?
scalar(@
$data) : 0;
27 my $start = $page_size*$page;
28 my $end = $page_size*($page+1)-1;
30 for( my $i = $start; $i <= $end; $i++ ) {
32 push @data_window, $data->[$i];
35 my $pagination = $self->pagination_response($total_count, $page_size, $page);
36 return (\
@data_window, $pagination);