Ignore:
Timestamp:
11/28/10 19:30:07 (14 years ago)
Author:
nanardon
Message:
  • add search functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Search.pm

    r40 r43  
    2323=cut 
    2424 
    25 my $search_param = { 
    26     rows => Sophie->config()->{'max_reply'} || 20000, 
    27     order_by => [ 'name', 'evr using >>', 'issrc' ], 
    28     select => [ 'pkgid' ], 
    29 }; 
    30  
    3125sub index :Path :Args(0) { 
    3226    my ( $self, $c ) = @_; 
    3327 
    34     $c->response->body('Matched Sophie::Controller::Search in Search.'); 
     28    if ($c->req->param('page')) { 
     29        $c->req->params->{search} = $c->session->{search}; 
     30    } 
     31 
     32    if ($c->req->param('search')) { 
     33        $c->session->{search} = $c->req->param('search'); 
     34        $c->forward('fuzzy', [ undef, $c->req->param('search') ]); 
     35        my $pager = $c->stash->{rs}->pager; 
     36        $c->stash->{pager} = $pager; 
     37        $c->stash->{xmlrpc} = [ 
     38            $c->stash->{rs}->get_column('pkgid')->all 
     39        ]; 
     40    } 
     41} 
     42 
     43sub search_param : Private { 
     44    my ($self, $c) = @_; 
     45    my $r = { 
     46        rows => Sophie->config()->{'max_reply'} || 20000, 
     47        order_by => [ 'name', 'evr using >>', 'issrc' ], 
     48        select => [ 'pkgid' ], 
     49    }; 
     50    if (!$c->req->xmlrpc->method) { 
     51        $r->{page} = $c->req->param('page') || 1; 
     52        $r->{rows} = 25; 
     53    } 
     54    return $r; 
    3555} 
    3656 
     
    4868            { 
    4969                $searchspec->{release} 
    50                     ? (release => $searchspec->{release}) 
     70                    ? (version => $searchspec->{release}) 
    5171                    : () 
    5272            } 
     
    84104            ]      
    85105        }, 
    86         $search_param, 
     106        $c->forward('search_param'), 
    87107    )->get_column('pkgid')->all ] 
    88108 
     
    120140            ]      
    121141        }, 
    122         $search_param, 
     142        $c->forward('search_param'), 
    123143    )->get_column('pkgid')->all ] 
    124144} 
     
    151171            ]      
    152172        }, 
    153         $search_param, 
     173        $c->forward('search_param'), 
    154174    )->get_column('pkgid')->all ] 
    155175} 
     
    165185    )->get_column('pkgid'); 
    166186 
    167     $c->stash->{xmlrpc} = [ $c->model('Base')->resultset('Rpms')->search( 
     187    $c->stash->{rs} =  
     188 
     189        $c->model('Base')->resultset('Rpms')->search( 
    168190        { 
    169191            -and => [ 
     
    185207            ]      
    186208        }, 
    187         $search_param, 
    188     )->get_column('pkgid')->all ] 
     209        $c->forward('search_param'), 
     210    ); 
     211     
     212    if ($c->req->xmlrpc->method) { 
     213        $c->stash->{xmlrpc} = [  
     214            $c->stash->{rs}->get_column('pkgid')->all 
     215        ]; 
     216    } 
    189217} 
    190218 
     
    208236        }, 
    209237        { 
    210             %$search_param, 
     238            %{$c->forward('search_param')}, 
    211239            select => [  
    212240                "ts_rank_cd(to_tsvector('english', description),to_tsquery(?)) as rank", 
Note: See TracChangeset for help on using the changeset viewer.