1 | package Sophie::Controller::Maintainers; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN {extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | Sophie::Controller::Maintainers - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | =head2 maintainers.byrpm ( RPMNAME, [ DISTRIB ] ) |
---|
20 | |
---|
21 | Return the list of maintainers for rpm source name C<RPMNAME>. |
---|
22 | |
---|
23 | The optional C<DISTRIB> filter the result to this specific distribution. |
---|
24 | |
---|
25 | Result example: |
---|
26 | |
---|
27 | [ |
---|
28 | { |
---|
29 | 'owner' => 'rpmmaintainer', |
---|
30 | 'distribution' => 'Mandriva' |
---|
31 | 'vendor' => 'Mandriva' |
---|
32 | } |
---|
33 | ]; |
---|
34 | |
---|
35 | =head2 Url: /maintainers/<RPM>/<DISTRIB> |
---|
36 | |
---|
37 | Return the list of maintainers for source rpm named C<RPM> for distribution |
---|
38 | C<DISTRIB>. |
---|
39 | |
---|
40 | Theses alternatives are supported: |
---|
41 | |
---|
42 | /maintainers?rpm=<RPM>;distrib=<DISTRIB> |
---|
43 | |
---|
44 | /maintainers/rpm?distrib=<DISTRIB> |
---|
45 | |
---|
46 | =cut |
---|
47 | |
---|
48 | sub byrpm :Path :XMLRPC { |
---|
49 | my ($self, $c, $rpm, $distrib) = @_; |
---|
50 | $rpm ||= $c->req->param('rpm'); |
---|
51 | $distrib ||= $c->req->param('distrib'); |
---|
52 | |
---|
53 | $c->stash->{xmlrpc} = [ map { { $_->get_columns } } |
---|
54 | $c->model('Base::MaintRpm')-> |
---|
55 | search( |
---|
56 | { rpm => $rpm }, |
---|
57 | { select => [ qw(owner) ] }, |
---|
58 | )-> |
---|
59 | search_related('MaintSources')-> |
---|
60 | search_related('MaintDistrib')-> |
---|
61 | search_related('Distribution', |
---|
62 | $distrib ? { |
---|
63 | '-or' => [ |
---|
64 | { shortname => $distrib }, |
---|
65 | { name => $distrib }, |
---|
66 | ], |
---|
67 | } : (), |
---|
68 | )->search({}, |
---|
69 | { |
---|
70 | 'select' => [ qw'owner name label' ], |
---|
71 | 'as' => [ qw'owner distribution vendor' ], |
---|
72 | } |
---|
73 | )->all ]; |
---|
74 | } |
---|
75 | |
---|
76 | =head2 maintainers.bymaintainer ( MAINT, [ DISTRIB ] ) |
---|
77 | |
---|
78 | Return the list of rpms for maintainer C<MAINT>. |
---|
79 | |
---|
80 | The optional C<DISTRIB> filter the result to this specific distribution. |
---|
81 | |
---|
82 | Result example: |
---|
83 | |
---|
84 | [ |
---|
85 | { |
---|
86 | 'rpm' => 'rpm package', |
---|
87 | 'distribution' => 'Mandriva' |
---|
88 | 'vendor' => 'Mandriva' |
---|
89 | } |
---|
90 | ]; |
---|
91 | |
---|
92 | =cut |
---|
93 | |
---|
94 | |
---|
95 | sub bymaintainer : XMLRPC { |
---|
96 | my ($self, $c, $maint, $distrib) = @_; |
---|
97 | $c->stash->{xmlrpc} = [ map { { $_->get_columns } } |
---|
98 | $c->model('Base::MaintRpm')-> |
---|
99 | search( |
---|
100 | { owner => $maint }, |
---|
101 | { select => [ qw(rpm) ] }, |
---|
102 | )-> |
---|
103 | search_related('MaintSources')-> |
---|
104 | search_related('MaintDistrib')-> |
---|
105 | search_related('Distribution', |
---|
106 | $distrib ? { |
---|
107 | '-or' => [ |
---|
108 | { shortname => $distrib }, |
---|
109 | { name => $distrib }, |
---|
110 | ], |
---|
111 | } : (), |
---|
112 | )->search({}, |
---|
113 | { |
---|
114 | 'select' => [ qw'rpm name label' ], |
---|
115 | 'as' => [ qw'rpm distribution vendor' ], |
---|
116 | } |
---|
117 | )->all ]; |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | =head2 maintainers.search ( MAINT, [ DISTRIB ] ) |
---|
122 | |
---|
123 | Search the database for a maintainer matching C<MAINT>. |
---|
124 | |
---|
125 | The optional C<DISTRIB> filter the result to this specific distribution. |
---|
126 | |
---|
127 | Result example: |
---|
128 | |
---|
129 | [ |
---|
130 | { |
---|
131 | 'owner' => 'maintainer', |
---|
132 | 'distribution' => 'Mandriva' |
---|
133 | 'vendor' => 'Mandriva' |
---|
134 | } |
---|
135 | ]; |
---|
136 | |
---|
137 | =cut |
---|
138 | |
---|
139 | sub search :XMLRPC { |
---|
140 | my ($self, $c, $maint, $distrib) = @_; |
---|
141 | |
---|
142 | $c->stash->{xmlrpc} = [ map { { $_->get_columns } } |
---|
143 | $c->model('Base::MaintRpm')->search( |
---|
144 | { owner => { 'LIKE' => "%$maint%" } } |
---|
145 | )->search_related('MaintSources' |
---|
146 | )->search_related('MaintDistrib' |
---|
147 | )->search_related('Distribution', |
---|
148 | $distrib ? { |
---|
149 | '-or' => [ |
---|
150 | { shortname => $distrib }, |
---|
151 | { name => $distrib }, |
---|
152 | ], |
---|
153 | } : (), |
---|
154 | )->search({}, |
---|
155 | { |
---|
156 | 'select' => [ qw'owner name label' ], |
---|
157 | 'as' => [ qw'owner distribution vendor' ], |
---|
158 | 'group_by' => [ qw'owner name label' ], |
---|
159 | 'order_by' => [ qw'owner name label' ], |
---|
160 | } |
---|
161 | )->all ]; |
---|
162 | } |
---|
163 | |
---|
164 | =head1 AUTHOR |
---|
165 | |
---|
166 | Olivier Thauvin |
---|
167 | |
---|
168 | =head1 LICENSE |
---|
169 | |
---|
170 | This library is free software. You can redistribute it and/or modify |
---|
171 | it under the same terms as Perl itself. |
---|
172 | |
---|
173 | =cut |
---|
174 | |
---|
175 | __PACKAGE__->meta->make_immutable; |
---|
176 | |
---|
177 | 1; |
---|