1 | package Sophie::Controller::Search; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN {extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | Sophie::Controller::Search - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | |
---|
20 | =head2 index |
---|
21 | |
---|
22 | =cut |
---|
23 | |
---|
24 | sub index :Path :Args(0) { |
---|
25 | my ( $self, $c ) = @_; |
---|
26 | |
---|
27 | $c->response->body('Matched Sophie::Controller::Search in Search.'); |
---|
28 | } |
---|
29 | |
---|
30 | sub 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 | |
---|
43 | sub 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 | |
---|
69 | Olivier Thauvin |
---|
70 | |
---|
71 | =head1 LICENSE |
---|
72 | |
---|
73 | This library is free software. You can redistribute it and/or modify |
---|
74 | it under the same terms as Perl itself. |
---|
75 | |
---|
76 | =cut |
---|
77 | |
---|
78 | __PACKAGE__->meta->make_immutable; |
---|
79 | |
---|
80 | 1; |
---|