Ignore:
Timestamp:
12/05/10 21:04:15 (14 years ago)
Author:
nanardon
Message:
  • add rpm search by dated
File:
1 edited

Legend:

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

    r57 r80  
    306306} 
    307307 
     308=head2 search.rpms.bydate SEARCHSPEC TIMESTAMP 
     309 
     310Return a list of rpms files added since TIMESTAMP. 
     311TIMESTAMP must the number of second since 1970-01-01 (eq UNIX epoch). 
     312 
     313SEARCHSPEC is a struct with following key/value: 
     314 
     315=over 4 
     316 
     317=item distribution 
     318 
     319Limit search to this distribution 
     320 
     321=item release 
     322 
     323Limit search to this release 
     324 
     325=item arch 
     326 
     327Limit search to distribution of this arch 
     328 
     329=item src 
     330 
     331If set to true, limit search to source package, If set to false, limit search to 
     332binary package. 
     333 
     334=item name 
     335 
     336Limit search to rpm having this name 
     337 
     338=item rows 
     339 
     340Set maximum of results, the default is 10000. 
     341 
     342=back 
     343 
     344Each elements of the output is a struct: 
     345 
     346=over 4 
     347 
     348=item filename 
     349 
     350the rpm filename 
     351 
     352=item pkgid 
     353 
     354the identifier of the package 
     355 
     356=item distribution 
     357 
     358the distribution containing this package 
     359 
     360=item release 
     361 
     362the release containing this package 
     363 
     364=item arch 
     365 
     366the arch containing this package 
     367 
     368=item media 
     369 
     370the media containing this package 
     371 
     372=back 
     373 
     374=cut 
     375 
     376sub bydate : XMLRPCPath('/search/rpms/bydate') { 
     377    my ( $self, $c, $searchspec, $date ) = @_; 
     378 
     379    return $c->stash->{xmlrpc} = [ 
     380        map { 
     381            {  
     382                filename => $_->get_column('filename'), 
     383                pkgid    => $_->get_column('pkgid'),  
     384                distribution => $_->get_column('name'), 
     385                release => $_->get_column('version'), 
     386                arch => $_->get_column('arch'), 
     387                media => $_->get_column('label'), 
     388            } 
     389        } 
     390        $c->forward('/distrib/distrib_rs', [ $searchspec ]) 
     391        ->search_related('MediasPaths') 
     392        ->search_related('Paths') 
     393        ->search_related('Rpmfiles', 
     394            { 
     395                -nest => \[ 
     396                    "Rpmfiles.added > '1970-01-01'::date + ?::interval", 
     397                    [ plain_text => "$date seconds" ],    
     398                ], 
     399                pkgid => { 
     400                    IN => $c->model('Base::Rpms')->search( 
     401                        { 
     402                            (exists($searchspec->{name}) 
     403                                ? (name => $searchspec->{name}) 
     404                                : () 
     405                            ), 
     406                            (exists($searchspec->{src}) 
     407                                ? (issrc => $searchspec->{src} ? 1 : 0) 
     408                                : () 
     409                            ), 
     410                        } 
     411                    )->get_column('pkgid')->as_query, 
     412                } 
     413            }, 
     414            { 
     415                select => [qw(filename pkgid name version arch label) ], 
     416                rows => $searchspec->{rows} || 10000, 
     417                order_by => [ 'Rpmfiles.added desc' ], 
     418            }, 
     419        )->all ]; 
     420} 
     421 
    308422=head1 AUTHOR 
    309423 
Note: See TracChangeset for help on using the changeset viewer.