r1842@llin: dpavlin | 2009-04-25 23:25:15 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 25 Apr 2009 21:25:15 +0000 (21:25 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 25 Apr 2009 21:25:15 +0000 (21:25 +0000)
 fix seeking in search results and returning only single page

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1170 07558da8-63fa-0310-ba24-9fe276d99e06

vhost/webpac2.cgi

index 79adc7d..b0a919e 100755 (executable)
@@ -218,6 +218,8 @@ if ( my $search = param('search') ) {
 
        $pager->total_entries( $swish_results->hits );
 
+       $swish_results->seek_result( $pager->first );
+
        if ( ! $pager->total_entries ) {
                my $no_results = 'No results for search <b>%s</b>';
                $no_results = $swish->error_string . '<br><b>%s</b>' if $swish->error;
@@ -234,7 +236,11 @@ if ( my $search = param('search') ) {
                my $start = $pager->first;
                print qq|<ol start=$start>\n|;
 
+               my $limit = $pager->entries_on_this_page;
+
                while ( my $result = $swish_results->next_result ) {
+                       last if $limit-- == 0;
+
                        my $data = from_json $result->property('data');
 
                        dump_yaml( 'data', $data );