1 | package Sophie::Controller::Rpms; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN {extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | Sophie::Controller::Rpms - 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::Rpms in Rpms.'); |
---|
28 | } |
---|
29 | |
---|
30 | sub queryformat : XMLRPCLocal { |
---|
31 | my ( $self, $c, $pkgid, $qf ) = @_; |
---|
32 | @{$c->stash->{xmlrpc}} = map { $_->get_column('qf') } $c->model('Base')->resultset('Rpms')->search( |
---|
33 | { pkgid => $pkgid }, |
---|
34 | { |
---|
35 | select => [ qq{rpmqueryformat("header", ?)} ], |
---|
36 | as => [ 'qf' ], |
---|
37 | bind => [ $qf ], |
---|
38 | } |
---|
39 | )->all; |
---|
40 | } |
---|
41 | |
---|
42 | sub tag : XMLRPCLocal { |
---|
43 | my ( $self, $c, $pkgid, $tag ) = @_; |
---|
44 | @{$c->stash->{xmlrpc}} = map { $_->get_column('tag') } $c->model('Base')->resultset('Rpms')->search( |
---|
45 | { pkgid => $pkgid }, |
---|
46 | { |
---|
47 | select => [ qq{rpmquery("header", rpmtag(?))} ], |
---|
48 | as => [ 'tag' ], |
---|
49 | bind => [ $tag ], |
---|
50 | } |
---|
51 | )->all; |
---|
52 | } |
---|
53 | |
---|
54 | sub deps : XMLRPCLocal { |
---|
55 | my ($self, $c, $pkgid, $deptype) = @_; |
---|
56 | |
---|
57 | @{ $c->stash->{xmlrpc}{deps}{$deptype} } = |
---|
58 | map { |
---|
59 | { |
---|
60 | name => $_->get_column('depname'), |
---|
61 | flags => $_->get_column('flags'), |
---|
62 | evr => $_->get_column('evr'), |
---|
63 | sense => $_->get_column('sense'), |
---|
64 | } |
---|
65 | } |
---|
66 | $c->model('Base')->resultset('Deps')->search( |
---|
67 | { |
---|
68 | pkgid => $pkgid, |
---|
69 | deptype => $deptype, |
---|
70 | }, |
---|
71 | { |
---|
72 | order_by => [ 'count' ], |
---|
73 | select => [ 'rpmsenseflag("flags")', qw(depname flags evr) ], |
---|
74 | as => [ qw'sense depname flags evr' ], |
---|
75 | |
---|
76 | }, |
---|
77 | )->all; |
---|
78 | } |
---|
79 | |
---|
80 | sub alldeps : XMLRPCLocal { |
---|
81 | my ($self, $c, $pkgid) = @_; |
---|
82 | |
---|
83 | foreach ( |
---|
84 | $c->model('Base')->resultset('Deps')->search( |
---|
85 | { |
---|
86 | pkgid => $pkgid, |
---|
87 | }, |
---|
88 | { |
---|
89 | order_by => [ 'count' ], |
---|
90 | select => [ 'rpmsenseflag("flags")', |
---|
91 | qw(depname flags evr deptype) ], |
---|
92 | as => [ qw'sense depname flags evr deptype' ], |
---|
93 | |
---|
94 | }, |
---|
95 | )->all) { |
---|
96 | push( @{ $c->stash->{xmlrpc}{deps}{$_->get_column('deptype')} }, |
---|
97 | { |
---|
98 | name => $_->get_column('depname'), |
---|
99 | flags => $_->get_column('flags'), |
---|
100 | evr => $_->get_column('evr'), |
---|
101 | sense => $_->get_column('sense'), |
---|
102 | } |
---|
103 | ); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | sub files : XMLRPCLocal { |
---|
108 | my ($self, $c, $pkgid) = @_; |
---|
109 | |
---|
110 | @{ $c->stash->{xmlrpc}{files} } = map { |
---|
111 | { |
---|
112 | filename => $_->get_column('dirname') . $_->get_column('basename'), |
---|
113 | md5 => $_->get_column('md5'), |
---|
114 | } |
---|
115 | } $c->model('Base')->resultset('Files')->search( |
---|
116 | { |
---|
117 | pkgid => $pkgid, |
---|
118 | }, |
---|
119 | { |
---|
120 | order_by => [ 'count' ], |
---|
121 | |
---|
122 | }, |
---|
123 | )->all; |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | sub rpms : Chained : PathPart { |
---|
128 | my ( $self, $c, $pkgid ) = @_; |
---|
129 | $c->stash->{pkgid} = $c->model('Base::Rpms')->search(pkgid => $pkgid)->next; |
---|
130 | $c->log->debug('rpms ' . $c->stash->{pkgid}); |
---|
131 | } |
---|
132 | |
---|
133 | =head1 AUTHOR |
---|
134 | |
---|
135 | Olivier Thauvin |
---|
136 | |
---|
137 | =head1 LICENSE |
---|
138 | |
---|
139 | This library is free software. You can redistribute it and/or modify |
---|
140 | it under the same terms as Perl itself. |
---|
141 | |
---|
142 | =cut |
---|
143 | |
---|
144 | __PACKAGE__->meta->make_immutable; |
---|
145 | |
---|
146 | 1; |
---|