source: server/web/lib/Sophie/Controller/Search.pm @ 12

Last change on this file since 12 was 6, checked in by nanardon, 14 years ago
  • add base updater daemon
File size: 1.9 KB
Line 
1package Sophie::Controller::Search;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Search - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27    $c->response->body('Matched Sophie::Controller::Search in Search.');
28}
29
30sub bytag : XMLRPCPath('/search/rpm/bytag') {
31    my ( $self, $c, $searchspec, $tag, $tagvalue ) = @_;
32
33    @{$c->stash->{xmlrpc}} = $c->model('Base')->resultset('Rpms')->search(
34        {
35            pkgid => { IN => $c->model('Base')->resultset('Tags')
36                ->search({ tagname => $tag, value => $tagvalue})
37                ->get_column('pkgid')->as_query }
38        }
39    )->get_column('pkgid')->all
40
41}
42
43sub bydep : XMLRPCPath('/search/rpm/bydep') {
44    my ( $self, $c, $searchspec, $deptype, $depname, $depsense, $depevr ) = @_;
45
46    @{$c->stash->{xmlrpc}} = $c->model('Base')->resultset('Rpms')->search(
47        {
48            pkgid => { IN => $c->model('Base')->resultset('Deps')
49                ->search({
50                        deptype => $deptype,
51                        depname => $depname,
52                        ($depsense
53                            ? (-nest => \[
54                                'rpmdepmatch(flags, evr, rpmsenseflag(?), ?)',
55                                     [ plain_text => $depsense],
56                                     [ plain_text => $depevr ]
57                                 ])
58                            : ()
59                        ),
60                })
61                ->get_column('pkgid')->as_query }
62        }
63    )->get_column('pkgid')->all
64
65}
66
67=head1 AUTHOR
68
69Olivier Thauvin
70
71=head1 LICENSE
72
73This library is free software. You can redistribute it and/or modify
74it under the same terms as Perl itself.
75
76=cut
77
78__PACKAGE__->meta->make_immutable;
79
801;
Note: See TracBrowser for help on using the repository browser.