source: server/trunk/web/lib/Sophie/Controller/Maintainers.pm @ 265

Last change on this file since 265 was 164, checked in by nanardon, 13 years ago
  • add /maintainers functions
File size: 1.9 KB
Line 
1package Sophie::Controller::Maintainers;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Maintainers - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19=head2 maintainers.byrpm ( RPMNAME, [ DISTRIB ] )
20
21Return the list of maintainers for rpm source name C<RPMNAME>.
22
23The optional C<DISTRIB> filter the result to this specific distribution.
24
25Result exemple:
26
27    [
28        {
29            'owner' => 'rpmmaintainer',
30            'distribution' => 'Mandriva'
31            'vendor' => 'Mandriva'
32        }
33    ];
34
35=head2 Url: /maintainers/<RPM>/<DISTRIB>
36
37Return the list of maintainers for source rpm named C<RPM> for distribution
38C<DISTRIB>.
39
40This alternatives are supported:
41
42    /maintainers?rpm=<RPM>;distrib=<DISTRIB>
43
44    /maintainers/rpm?distrib=<DISTRIB>
45
46=cut
47
48sub 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
77=head1 AUTHOR
78
79Olivier Thauvin
80
81=head1 LICENSE
82
83This library is free software. You can redistribute it and/or modify
84it under the same terms as Perl itself.
85
86=cut
87
88__PACKAGE__->meta->make_immutable;
89
901;
Note: See TracBrowser for help on using the repository browser.