source: server/trunk/web/lib/Sophie/Controller/Sources.pm @ 97

Last change on this file since 97 was 97, checked in by nanardon, 14 years ago
  • add sources/ sub section
File size: 2.8 KB
Line 
1package Sophie::Controller::Sources;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Sources - 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::Sources in Sources.');
28}
29
30sub srcfiles : XMLRPCLocal {
31    my ($self, $c, $searchspec, $name) = @_;
32
33    my $distrs = $c->forward('/search/distrib_search', [ $searchspec, 1 ]);
34    my $rpmrs = ($distrs
35        ? $distrs->search_related('RpmsFile')
36        : undef);
37
38    $c->stash->{xmlrpc} = [ 
39        map {
40         { $_->get_columns }
41        }
42       
43        $c->model('Base::Rpms')
44        ->search(
45            { 
46                name => $name,
47                issrc => 1,
48                $rpmrs
49                    ? (pkgid => { IN => $rpmrs->get_column('pkgid')->as_query },)
50                    : (),
51            },
52            {
53                select => [ 'evr' ],
54            }
55        )->search_related('SrcFiles')->search(
56            {
57                #has_content => 1,
58            },
59            {
60                    select => [ 'basename', 'evr', 'SrcFiles.pkgid' ],
61                    group_by => [ 'basename', 'evr', 'SrcFiles.pkgid' ],
62                    order_by => [ 'evr using >>', 'basename' ],
63            }
64        )->all ];
65}
66
67sub srcfilesbyfile : XMLRPCLocal {
68    my ($self, $c, $searchspec, $name, $filename) = @_;
69
70    my $distrs = $c->forward('/search/distrib_search', [ $searchspec, 1 ]);
71    my $rpmrs = ($distrs
72        ? $distrs->search_related('RpmsFile')
73        : undef);
74
75    $c->stash->{xmlrpc} = [ 
76        map {
77         { $_->get_columns }
78        }
79       
80        $c->model('Base::Rpms')
81        ->search(
82            { 
83                name => $name,
84                issrc => 1,
85                $rpmrs
86                    ? (pkgid => { IN => $rpmrs->get_column('pkgid')->as_query },)
87                    : (),
88            },
89            {
90                select => [ 'evr' ],
91            }
92        )->search_related('SrcFiles')->search(
93            {
94                #has_content => 1,
95                basename => $filename,
96            },
97            {
98                    order_by => [ 'evr using >>' ],
99            }
100        )->all ];
101
102}
103
104sub rpm_sources :Path :Args(1) {
105    my ($self, $c, $rpm) = @_;
106
107    $c->forward('srcfiles', [ {}, $rpm ]);
108
109}
110
111sub rpm_sources_file :Path :Args(2) {
112    my ($self, $c, $rpm, $filename) = @_;
113
114    $c->forward('srcfilesbyfile', [ {}, $rpm, $filename ]);
115
116}
117
118=head1 AUTHOR
119
120Olivier Thauvin
121
122=head1 LICENSE
123
124This library is free software. You can redistribute it and/or modify
125it under the same terms as Perl itself.
126
127=cut
128
129__PACKAGE__->meta->make_immutable;
130
1311;
Note: See TracBrowser for help on using the repository browser.