Skip to content

Commit

Permalink
Internal param for search to request specific number of results
Browse files Browse the repository at this point in the history
  • Loading branch information
lomky committed Feb 15, 2018
1 parent 9627fe1 commit 145ddfb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Tuba/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ sub keyword {
my $orm = $c->orm;
my @tables = keys %$orm;
my $type = $c->param('type');
my $count = $c->param('count') || -1;
@tables = ( $type ) if $type && exists($orm->{$type});
my @results;
my $result_count_text;
my $hit_max = 0;
my $limit;
if ( @tables > 1 ) {
$limit = 10;
} elsif ( $count > 0 && $count < 50 ) {
$limit = $count;
} else {
$limit = 50;
}
for my $table (@tables) {
next if $table eq 'publication';
my $manager = $orm->{$table}->{mng};
next unless $manager->has_urls($c);
my @these = $manager->dbgrep(query_string => $q, user => $c->user, limit => (@tables > 1 ? 10 : 50));
my @these = $manager->dbgrep(query_string => $q, user => $c->user, limit => $limit );
$hit_max = 1 if @these==10 && @tables > 1;
push @results, @these;
}
Expand Down

0 comments on commit 145ddfb

Please sign in to comment.