|
|
|
|
@ -701,19 +701,31 @@ sub paginate_order_collection_rs {
|
|
|
|
|
rows => $rows,
|
|
|
|
|
});
|
|
|
|
|
$self->define_collection_infinite_pager($c, undef, $item_rs, $rows, $no_count);
|
|
|
|
|
|
|
|
|
|
if ($order_by && ((my $explicit = ($self->can('order_by_cols') && exists $self->order_by_cols()->{$order_by})) or $item_rs->result_source->has_column($order_by))) {
|
|
|
|
|
my $col = ($explicit ? $self->order_by_cols()->{$order_by} : $item_rs->current_source_alias . '.' . $order_by);
|
|
|
|
|
if (lc($direction) eq 'desc') {
|
|
|
|
|
$item_rs = $item_rs->search(undef, {
|
|
|
|
|
order_by => {-desc => $col},
|
|
|
|
|
});
|
|
|
|
|
$c->log->debug("ordering by $col DESC");
|
|
|
|
|
} else {
|
|
|
|
|
$item_rs = $item_rs->search(undef, {
|
|
|
|
|
order_by => "$col",
|
|
|
|
|
});
|
|
|
|
|
$c->log->debug("ordering by $col");
|
|
|
|
|
if ($order_by) {
|
|
|
|
|
my $explicit_order_col_spec;
|
|
|
|
|
if ($self->can('order_by_cols')) {
|
|
|
|
|
my($explicit_order_cols,$explicit_order_cols_params) = $self->order_by_cols();
|
|
|
|
|
$explicit_order_col_spec = $explicit_order_cols->{$order_by};
|
|
|
|
|
$explicit_order_cols_params //= {};
|
|
|
|
|
if ( exists $explicit_order_cols_params->{$order_by}->{join} ) {
|
|
|
|
|
$item_rs = $item_rs->search(undef, {
|
|
|
|
|
join => $explicit_order_cols_params->{$order_by}->{join},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($explicit_order_col_spec or $item_rs->result_source->has_column($order_by)) {
|
|
|
|
|
my $col = $explicit_order_col_spec || $item_rs->current_source_alias . '.' . $order_by;
|
|
|
|
|
if (lc($direction) eq 'desc') {
|
|
|
|
|
$item_rs = $item_rs->search(undef, {
|
|
|
|
|
order_by => {-desc => $col},
|
|
|
|
|
});
|
|
|
|
|
$c->log->debug("ordering by $col DESC");
|
|
|
|
|
} else {
|
|
|
|
|
$item_rs = $item_rs->search(undef, {
|
|
|
|
|
order_by => "$col",
|
|
|
|
|
});
|
|
|
|
|
$c->log->debug("ordering by $col");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
my $result_class_after = $item_rs->result_class();
|
|
|
|
|
|