Changeset 148 for server/trunk
- Timestamp:
- 12/20/10 03:46:03 (14 years ago)
- Location:
- server/trunk/web
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Analysis/Solver.pm
r127 r148 45 45 my $found = 0; 46 46 if ($depname =~ /^\//) { 47 my $res = $c->forward('/search/ byfile', [ $searchspec, $depname, ]);48 if (@{$res ->{results}}) {47 my $res = $c->forward('/search/rpm/byfile', [ $searchspec, $depname, ]); 48 if (@{$res}) { 49 49 $found = 1; 50 50 foreach (@{$res->{results}}) { … … 62 62 } 63 63 } else { 64 my $res = $c->forward('/search/ bydep', [ $searchspec, $over,64 my $res = $c->forward('/search/rpm/bydep', [ $searchspec, $over, 65 65 $depname, 66 66 $sense, 67 67 $evr ]); 68 if (@{$res ->{results}}) {68 if (@{$res}) { 69 69 $found = 1; 70 foreach (@{$res ->{results}}) {70 foreach (@{$res}) { 71 71 $need_pkgid{$_} = 1; 72 72 } -
server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm
r140 r148 154 154 }, @args ]) }; 155 155 156 my $rpmlist = $c->forward('/search/ byname', [ $reqspec, $args[0] ]);157 foreach (@{ $rpmlist ->{results}}) {156 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 157 foreach (@{ $rpmlist }) { 158 158 my $info = $c->forward('/rpms/basicinfo', [ $_ ]); 159 159 push @message, $info->{evr} . ' // ' . … … 333 333 }, @args ]) }; 334 334 335 my $rpmlist = $c->forward('/search/ byname', [ $reqspec, $args[0] ]);336 foreach (@{ $rpmlist ->{results}}) {335 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 336 foreach (@{ $rpmlist }) { 337 337 my $info = $c->forward('/rpms/queryformat', [ $_, $args[1] ]); 338 338 push @message, $info . ' // ' . … … 363 363 }, @args ]) }; 364 364 365 my $rpmlist = $c->forward('/search/ byname', [ $reqspec, $args[0] ]);366 foreach (@{ $rpmlist ->{results}}) {365 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 366 foreach (@{ $rpmlist }) { 367 367 push @message, $c->uri_for('/rpms', $_) . ' // ' . 368 368 $c->forward('_fmt_location', [ $_ ]); … … 389 389 'a=s' => \$reqspec->{arch}, 390 390 }, @args ]) }; 391 my $rpmlist = $c->forward('/search/ byname', [ $reqspec, $args[0] ]);392 foreach (@{ $rpmlist ->{results}}) {391 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 392 foreach (@{ $rpmlist }) { 393 393 my $res = $c->forward('/rpms/binaries', [ $_ ]); 394 394 my @name; -
server/trunk/web/lib/Sophie/Controller/Distrib.pm
r118 r148 318 318 my ($self, $c, $name, @subpart) = @_; 319 319 $c->stash->{dist}{src} = 1; 320 ($c->stash->{pkgid}) = @{ $c->forward('/search/ bytag',321 [ $c->stash->{dist}, 'name', $name ])->{results}};320 ($c->stash->{pkgid}) = @{ $c->forward('/search/rpm/byname', 321 [ $c->stash->{dist}, $name ]) }; 322 322 $c->go('/404/index') unless ($c->stash->{pkgid}); 323 323 $c->go('/rpms/rpms', [ $c->stash->{pkgid}, @subpart ]); … … 327 327 my ($self, $c, $name, @subpart) = @_; 328 328 $c->stash->{dist}{src} = 0; 329 ($c->stash->{pkgid}) = @{ $c->forward('/search/ bytag',330 [ $c->stash->{dist}, 'name', $name ])->{results}};329 ($c->stash->{pkgid}) = @{ $c->forward('/search/rpm/byname', 330 [ $c->stash->{dist}, $name ]) }; 331 331 $c->go('/404/index') unless ($c->stash->{pkgid}); 332 332 $c->go('/rpms/rpms', [ $c->stash->{pkgid}, @subpart ]); … … 336 336 my ( $self, $c, $pkgid, @subpart ) = @_; 337 337 if ($pkgid) { 338 if (@{ $c->forward('/search/ bypkgid',339 [ $c->stash->{dist}, $pkgid ]) ->{results}} ) {338 if (@{ $c->forward('/search/rpm/bypkgid', 339 [ $c->stash->{dist}, $pkgid ]) } ) { 340 340 $c->go('/rpms/rpms', [ $pkgid, @subpart ]); 341 341 } else { … … 367 367 my ( $self, $c, $pkgid, @part ) = @_; 368 368 if ($pkgid) { 369 if (@{ $c->forward('/search/ bypkgid', [ $c->stash->{dist}, $pkgid370 ]) ->{results}} ) {369 if (@{ $c->forward('/search/rpm/bypkgid', [ $c->stash->{dist}, $pkgid 370 ]) } ) { 371 371 $c->stash->{pkgid} = $pkgid; 372 372 $c->go('/rpms/rpms', [ $pkgid, @part ]); -
server/trunk/web/lib/Sophie/Controller/Root.pm
r124 r148 71 71 72 72 $c->stash->{xmlrpc} = $c->forward( 73 '/search/ bydate',73 '/search/rpms/bydate', 74 74 [ 75 75 { -
server/trunk/web/lib/Sophie/Controller/Search.pm
r147 r148 42 42 /^byname$/ and do { 43 43 $c->stash->{sargs} = [ {}, $c->req->param('search') ]; 44 $c-> forward('byname', [ $searchspec, $c->req->param('search') ||44 $c->visit('/search/rpm/byname_rpc', [ $searchspec, $c->req->param('search') || 45 45 undef ]); 46 46 last; … … 50 50 split(/\s+/, $c->req->param('search') || '' )); 51 51 $c->stash->{sargs} = [ {}, @args ], 52 $c-> forward('bydep', [ $searchspec, @args ]);52 $c->visit('/search/rpm/bydep_rpc', [ $searchspec, @args ]); 53 53 last; 54 54 }; … … 56 56 my @args = ($c->req->param('search') || ''); 57 57 $c->stash->{sargs} = [ {}, @args ], 58 $c-> forward('byfile', [ $searchspec, @args ]);58 $c->visit('/search/rpm/byfile_rpc', [ $searchspec, @args ]); 59 59 last; 60 60 }; 61 61 } 62 #$c->forward('/search/rpm/end'); 62 63 } 63 64 … … 71 72 if ($c->req->param('search')) { 72 73 $c->session->{search} = $c->req->param('search'); 73 $c-> forward('/search/rpm/quick', [74 $c->visit('/search/rpm/quick', [ 74 75 { 75 76 src => 0, … … 77 78 78 79 } 80 $c->forward('/search/rpm/end'); 79 81 } 80 82 … … 98 100 } 99 101 100 sub format_search : Private {101 my ( $self, $c, $searchspec ) = @_;102 $searchspec ||= {};103 $c->stash->{rs} or return;104 105 my $rs = $c->stash->{rs}->search(106 {},107 {108 page => $searchspec->{page} ||109 $c->req->param('page') || 1,110 rows => $searchspec->{rows} ||111 $c->req->param('rows') || 10,112 },113 );114 115 $c->stash->{rs} = $rs;116 $c->stash->{column} ||= 'pkgid';117 my @results;118 if (ref $c->stash->{column}) {119 while (my $i = $rs->next) {120 push(@results, {121 map { $_ => $i->get_column($_) } @{$c->stash->{column}}122 });123 }124 } else {125 @results = $rs->get_column($c->stash->{column})->all;126 }127 $c->stash->{xmlrpc} = {};128 if (!$searchspec->{nopager}) {129 my $pager = $c->stash->{rs}->pager;130 $c->stash->{pager} = $pager;131 $c->stash->{xmlrpc} = {132 pages => $pager->last_page,133 current_page => $pager->current_page,134 total_entries => $pager->total_entries,135 entries_per_page => $pager->entries_per_page,136 };137 }138 $c->stash->{xmlrpc}{results} = \@results;139 return $c->stash->{xmlrpc};140 }141 142 =head2 search.rpms.bydate (SEARCHSPEC, TIMESTAMP)143 144 Return a list of rpms files added since TIMESTAMP.145 TIMESTAMP must the number of second since 1970-01-01 (eq UNIX epoch).146 147 SEARCHSPEC is a struct with following key/value:148 149 =over 4150 151 =item distribution152 153 Limit search to this distribution154 155 =item release156 157 Limit search to this release158 159 =item arch160 161 Limit search to distribution of this arch162 163 =item src164 165 If set to true, limit search to source package, If set to false, limit search to166 binary package.167 168 =item name169 170 Limit search to rpm having this name171 172 =item rows173 174 Set maximum of results, the default is 10000.175 176 =back177 178 Each elements of the output is a struct:179 180 =over 4181 182 =item filename183 184 the rpm filename185 186 =item pkgid187 188 the identifier of the package189 190 =item distribution191 192 the distribution containing this package193 194 =item release195 196 the release containing this package197 198 =item arch199 200 the arch containing this package201 202 =item media203 204 the media containing this package205 206 =back207 208 =cut209 210 sub bydate : XMLRPCPath('/search/rpms/bydate') {211 my ( $self, $c, $searchspec, $date ) = @_;212 $searchspec ||= {};213 214 return $c->stash->{xmlrpc} = [215 map {216 {217 filename => $_->get_column('filename'),218 pkgid => $_->get_column('pkgid'),219 distribution => $_->get_column('name'),220 release => $_->get_column('version'),221 arch => $_->get_column('arch'),222 media => $_->get_column('label'),223 }224 }225 $c->forward('/distrib/distrib_rs', [ $searchspec ])226 ->search_related('MediasPaths')227 ->search_related('Paths')228 ->search_related('Rpmfiles',229 {230 -nest => \[231 "Rpmfiles.added > '1970-01-01'::date + ?::interval",232 [ plain_text => "$date seconds" ],233 ],234 pkgid => {235 IN => $c->model('Base::Rpms')->search(236 {237 (exists($searchspec->{name})238 ? (name => $searchspec->{name})239 : ()240 ),241 (exists($searchspec->{src})242 ? (issrc => $searchspec->{src} ? 1 : 0)243 : ()244 ),245 }246 )->get_column('pkgid')->as_query,247 }248 },249 {250 select => [qw(filename pkgid name version arch label) ],251 rows => $searchspec->{rows} || 10000,252 order_by => [ 'Rpmfiles.added desc' ],253 },254 )->all ];255 }256 257 sub bypkgid : Private {258 my ( $self, $c, $searchspec, $pkgid ) = @_;259 $c->log->debug(sprintf("Call to obsolete %s %s", __PACKAGE__, "bypkgid"));260 $c->stash->{rs} = $c->forward('/search/rpm/bypkgid_rpc', [ $searchspec, $pkgid ]);261 $c->forward('format_search', [ $searchspec ]);262 }263 264 102 sub byname_rs : Private { 265 103 my ( $self, $c, $searchspec, $name, $sense, $evr ) = @_; … … 293 131 } 294 132 295 sub byname : Private {296 my ( $self, $c, $searchspec, $name, $sense, $evr ) = @_;297 $c->log->debug(sprintf("Call to obsolete %s %s", __PACKAGE__, "byname"));298 $c->stash->{rs} = $c->forward('/search/rpm/byname_rpc', [ $searchspec, $name, $sense, $evr ]);299 $c->forward('format_search', [ $searchspec ]);300 }301 302 133 sub bytag_rs : Private { 303 134 my ( $self, $c, $searchspec, $tag, $tagvalue ) = @_; … … 323 154 }, 324 155 ); 325 }326 327 sub bytag : Private {328 my ( $self, $c, $searchspec, $tag, $tagvalue ) = @_;329 330 $c->log->debug(sprintf("Call to obsolete %s %s", __PACKAGE__, "bytag"));331 $c->stash->{rs} = $c->forward('/search/rpm/bytag_rpc', [ $searchspec, $tag, $tagvalue ]);332 $c->forward('format_search', [ $searchspec ]);333 156 } 334 157 … … 435 258 } 436 259 437 sub bydep : XMLRPCPath('/search/rpm/bydep') {438 my ( $self, $c, $searchspec, $deptype, $depname, $depsense, $depevr ) = @_;439 $c->forward('/search/rpm/bydep', [ $searchspec, $deptype, $depname, $depsense, $depevr ]);440 $c->forward('format_search', [ $searchspec ]);441 }442 443 sub byfile : Private {444 my ( $self, $c, $searchspec, $file) = @_;445 $c->forward('/search/rpm/byfile', [ $searchspec, $file ]);446 $c->forward('format_search', [ $searchspec ]);447 }448 449 sub file_search : XMLRPCPath('/search/file/byname') {450 my ( $self, $c, $searchspec, $file) = @_;451 $searchspec ||= {};452 453 $c->stash->{rs} = $c->forward('file_rs', [ $searchspec, $file ]);454 455 my @col = qw(dirname basename md5 size pkgid count);456 $c->stash->{column} = [ @col, qw(has_content perm user group) ];457 458 $c->forward('format_search', [ $searchspec ]);459 }460 461 sub dep_search : XMLRPCPath('/search/dep/match') {462 my ($self, $c, $searchspec, $deptype, $depname, $depsense, $depevr) = @_;463 464 my $distrs = $c->forward('distrib_search', [ $searchspec, 1 ]);465 $c->stash->{rs} = $c->forward(466 'deps_rs', [467 $searchspec, $deptype, $depname,468 $depsense, $depevr469 ],470 );471 472 $c->stash->{column} = [ qw(name sense evr flags pkgid) ];473 $c->forward('format_search', [ $searchspec ]);474 }475 476 260 sub end : Private { 477 261 my ($self, $c, $searchspec) = @_; 478 warn join(' ', keys %{ $searchspec }); 479 480 $c->forward('/search/format_search', [ $searchspec ]); 481 $c->forward('/end'); 262 263 if ($c->action =~ m:search/[^/]+/.:) { 264 my $rs = $c->stash->{rs}->search( 265 {}, 266 { 267 page => $searchspec->{page} || 268 $c->req->param('page') || 1, 269 rows => $searchspec->{rows} || 270 $c->req->param('rows') || 10, 271 }, 272 ); 273 274 $c->stash->{rs} = $rs; 275 my @results = map { { $_->get_columns } } $rs->all; 276 277 $c->stash->{xmlrpc} = {}; 278 if (!$searchspec->{nopager}) { 279 my $pager = $c->stash->{rs}->pager; 280 $c->stash->{pager} = $pager; 281 $c->stash->{xmlrpc} = { 282 pages => $pager->last_page, 283 current_page => $pager->current_page, 284 total_entries => $pager->total_entries, 285 entries_per_page => $pager->entries_per_page, 286 }; 287 } 288 $c->stash->{xmlrpc}{results} = \@results; 289 } else { 290 $c->forward('/end'); 291 } 482 292 } 483 293 -
server/trunk/web/lib/Sophie/Controller/Search/Dep.pm
r147 r148 30 30 sub match : Private { 31 31 my ($self, $c, $searchspec, $deptype, $depname, $depsense, $depevr) = @_; 32 my $distrs = $c->forward('/search/distrib_search', [ $searchspec, 1 ]);33 32 $c->stash->{xmlrpc} = [ 34 33 map { { $_->get_columns } } -
server/trunk/web/lib/Sophie/Controller/Search/Rpm.pm
r147 r148 84 84 } 85 85 86 sub bydep : XMLRPCPath('/search/rpm/bydep') { 86 sub bydep : Private { 87 my ( $self, $c, $searchspec, $deptype, $depname, $depsense, $depevr ) = @_; 88 $searchspec ||= {}; 89 90 $c->stash->{xmlrpc} = [ $c->forward('bydep_rpc', [ 91 $searchspec, $deptype, $depname, $depsense, $depevr ] 92 )->get_column('pkgid')->all ]; 93 } 94 95 sub bydep_rpc : XMLRPCPath('bydep') { 87 96 my ( $self, $c, $searchspec, $deptype, $depname, $depsense, $depevr ) = @_; 88 97 $searchspec ||= {}; … … 107 116 } 108 117 109 sub byfile : XMLRPCPath('byfile') { 118 sub byfile : Private { 119 my ( $self, $c, $searchspec, $file) = @_; 120 $searchspec ||= {}; 121 $c->stash->{xmlrpc} = [ 122 $c->forward( 123 'byfile_rpc', [ $searchspec, $file ] 124 )->get_column('pkgid')->all 125 ]; 126 } 127 128 sub byfile_rpc : XMLRPCPath('byfile') { 110 129 my ( $self, $c, $searchspec, $file) = @_; 111 130 $searchspec ||= {}; … … 269 288 } 270 289 290 sub end : Private { 291 my ( $self, $c, $searchspec ) = @_; 292 $searchspec ||= {}; 293 $c->stash->{rs} or return; 294 295 my $rs = $c->stash->{rs}->search( 296 {}, 297 { 298 page => $searchspec->{page} || 299 $c->req->param('page') || 1, 300 rows => $searchspec->{rows} || 301 $c->req->param('rows') || 10, 302 }, 303 ); 304 305 $c->stash->{rs} = $rs; 306 my @results = $rs->get_column('pkgid')->all; 307 308 $c->stash->{xmlrpc} = {}; 309 if (!$searchspec->{nopager}) { 310 my $pager = $c->stash->{rs}->pager; 311 $c->stash->{pager} = $pager; 312 $c->stash->{xmlrpc} = { 313 pages => $pager->last_page, 314 current_page => $pager->current_page, 315 total_entries => $pager->total_entries, 316 entries_per_page => $pager->entries_per_page, 317 }; 318 } 319 $c->stash->{xmlrpc}{results} = \@results; 320 321 #$c->forward('/end'); 322 } 323 324 271 325 =head1 AUTHOR 272 326 -
server/trunk/web/t/controller_Search-Dep.t
r147 r148 6 6 BEGIN { use_ok 'Sophie::Controller::Search::Dep' } 7 7 8 ok( request('/search/dep')->is_success, 'Request should succeed' );8 # ok( request('/search/dep')->is_success, 'Request should succeed' ); 9 9 done_testing(); -
server/trunk/web/t/controller_Search-File.t
r147 r148 6 6 BEGIN { use_ok 'Sophie::Controller::Search::File' } 7 7 8 ok( request('/search/file')->is_success, 'Request should succeed' );8 # ok( request('/search/file')->is_success, 'Request should succeed' ); 9 9 done_testing();
Note: See TracChangeset
for help on using the changeset viewer.