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

Last change on this file since 306 was 297, checked in by nanardon, 13 years ago
  • resurect nb_rpm chat command
File size: 3.4 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
76sub bymaintainer : XMLRPC {
77    my ($self, $c, $maint, $distrib) = @_;
78    $c->stash->{xmlrpc} = [ map { { $_->get_columns } } 
79    $c->model('Base::MaintRpm')->
80        search(
81            { owner => $maint },
82            { select => [ qw(rpm) ] },
83        )->
84        search_related('MaintSources')->
85        search_related('MaintDistrib')->
86        search_related('Distribution',
87            $distrib ? {
88                '-or' => [
89                    { shortname => $distrib },
90                    { name => $distrib },
91                ],
92            } : (),
93        )->search({},
94            {
95                'select' => [ qw'rpm name label' ],
96                'as'     => [ qw'rpm distribution vendor' ],
97            }
98        )->all ];
99   
100}
101
102sub search :XMLRPC {
103    my ($self, $c, $maint, $distrib) = @_;
104
105    $c->stash->{xmlrpc} = [ map { { $_->get_columns } }
106        $c->model('Base::MaintRpm')->search(
107            { owner => { 'LIKE' => "%$maint%" } }
108        )->search_related('MaintSources'
109        )->search_related('MaintDistrib'
110        )->search_related('Distribution',
111            $distrib ? {
112                '-or' => [
113                    { shortname => $distrib },
114                    { name => $distrib },
115                ],
116            } : (),
117        )->search({},
118            {
119                'select' => [ qw'owner name label' ],
120                'as'     => [ qw'owner distribution vendor' ],
121                'group_by' => [ qw'owner name label' ],
122                'order_by' => [ qw'owner name label' ],
123            }
124        )->all ];
125}
126
127=head1 AUTHOR
128
129Olivier Thauvin
130
131=head1 LICENSE
132
133This library is free software. You can redistribute it and/or modify
134it under the same terms as Perl itself.
135
136=cut
137
138__PACKAGE__->meta->make_immutable;
139
1401;
Note: See TracBrowser for help on using the repository browser.