Changeset 80 for server/trunk/web/lib/Sophie/Controller/Search.pm
- Timestamp:
- 12/05/10 21:04:15 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Search.pm
r57 r80 306 306 } 307 307 308 =head2 search.rpms.bydate SEARCHSPEC TIMESTAMP 309 310 Return a list of rpms files added since TIMESTAMP. 311 TIMESTAMP must the number of second since 1970-01-01 (eq UNIX epoch). 312 313 SEARCHSPEC is a struct with following key/value: 314 315 =over 4 316 317 =item distribution 318 319 Limit search to this distribution 320 321 =item release 322 323 Limit search to this release 324 325 =item arch 326 327 Limit search to distribution of this arch 328 329 =item src 330 331 If set to true, limit search to source package, If set to false, limit search to 332 binary package. 333 334 =item name 335 336 Limit search to rpm having this name 337 338 =item rows 339 340 Set maximum of results, the default is 10000. 341 342 =back 343 344 Each elements of the output is a struct: 345 346 =over 4 347 348 =item filename 349 350 the rpm filename 351 352 =item pkgid 353 354 the identifier of the package 355 356 =item distribution 357 358 the distribution containing this package 359 360 =item release 361 362 the release containing this package 363 364 =item arch 365 366 the arch containing this package 367 368 =item media 369 370 the media containing this package 371 372 =back 373 374 =cut 375 376 sub 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 308 422 =head1 AUTHOR 309 423
Note: See TracChangeset
for help on using the changeset viewer.