Skip to content

Commit

Permalink
Merge pull request #3496 from solgenomics/topic/fix_pagination
Browse files Browse the repository at this point in the history
fix brapi search pagination
  • Loading branch information
lukasmueller authored Apr 23, 2021
2 parents 1dadadd + 1d85a3b commit 235d5f8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
5 changes: 4 additions & 1 deletion lib/CXGN/BrAPI/v2/BreedingMethods.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ sub search {
}

foreach (@crosstypes){
my $id = $_;
$id =~ s/ /_/g;

push @data, {
abbreviation=>$_,
breedingMethodDbId=>$_ =~ s/ /_/g,
breedingMethodDbId=>$id,
breedingMethodName=>$_,
description=>$_,
};
Expand Down
3 changes: 2 additions & 1 deletion lib/CXGN/BrAPI/v2/Results.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ sub save_results {

my $search_id = substr($tempfile, -16);
my %result = ( searchResultDbId => $search_id );
my $pagination = CXGN::BrAPI::Pagination->pagination_response(0,$page_size,$page);
#Pagination should be present in BrAPI only if data available in the result
my $pagination = {}; #CXGN::BrAPI::Pagination->pagination_response(0,$page_size,$page);
return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, "search $search_type result constructed");

}
Expand Down
26 changes: 16 additions & 10 deletions lib/SGN/Controller/AJAX/BrAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ sub germplasm_search_old_GET {
sub germplasm_search_old_POST {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('Germplasm');
Expand Down Expand Up @@ -1537,7 +1537,7 @@ sub allelematrix_GET {
sub allelematrix_search_process {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);

my $clean_inputs = $c->stash->{clean_inputs};
my $format = $clean_inputs->{format}->[0];
Expand Down Expand Up @@ -1899,7 +1899,7 @@ sub studies_search : Chained('brapi') PathPart('studies-search') Args(0) : Acti
sub studies_search_POST {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('Studies');
Expand Down Expand Up @@ -2497,7 +2497,7 @@ sub phenotypes_search : Chained('brapi') PathPart('phenotypes-search') Args(0) :
sub phenotypes_search_POST {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('ObservationUnits');
Expand Down Expand Up @@ -2652,7 +2652,7 @@ sub phenotypes_search_table_GET {
sub process_phenotypes_search_table {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('ObservationTables');
Expand Down Expand Up @@ -2692,7 +2692,7 @@ sub phenotypes_search_csv_GET {
sub process_phenotypes_search_csv {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $dir = $c->tempfiles_subdir('download');
my $time_stamp = strftime "%Y-%m-%dT%H%M%S", localtime();
Expand Down Expand Up @@ -2735,7 +2735,7 @@ sub phenotypes_search_tsv_GET {
sub process_phenotypes_search_tsv {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $dir = $c->tempfiles_subdir('download');
my $time_stamp = strftime "%Y-%m-%dT%H%M%S", localtime();
Expand Down Expand Up @@ -3238,7 +3238,7 @@ sub observationvariable_search_GET {
sub _observationvariable_search_process {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);

my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
Expand Down Expand Up @@ -3327,7 +3327,7 @@ sub samples_list_GET {
sub _sample_search_process {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('Samples');
Expand Down Expand Up @@ -4009,7 +4009,7 @@ sub observations_search_GET {
sub observations_search_process {
my $self = shift;
my $c = shift;
my ($auth) = _authenticate_user($c);
# my ($auth) = _authenticate_user($c);
my $clean_inputs = $c->stash->{clean_inputs};
my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper('Observations');
Expand Down Expand Up @@ -5084,6 +5084,12 @@ sub save_results {

my $brapi = $self->brapi_module;
my $brapi_module = $brapi->brapi_wrapper($search_type);

#set default value to 100000 to get as much as possible records when page size is not a parameter
if(!$search_params->{pageSize}) {
$brapi_module->{page_size} = 100000;
}

my $search_result = $brapi_module->search($search_params,$c);

my $dir = $c->tempfiles_subdir('/brapi_searches');
Expand Down
Loading

0 comments on commit 235d5f8

Please sign in to comment.