1 package NDWeb::Controller::Alliances;
5 use parent 'Catalyst::Controller';
9 NDWeb::Controller::Alliances - Catalyst Controller
24 sub index :Path :Args(0) {
25 my ( $self, $c ) = @_;
27 $c->response->body('Matched NDWeb::Controller::Alliances in Alliances.');
30 sub resources : Local {
31 my ( $self, $c, $order ) = @_;
34 if (defined $order && $order =~ /^(size|score|resources|hidden|resplanet|hidplanet|nscore|nscore2|nscore3)$/){
37 $order = "resplanet DESC";
40 my $query = $dbh->prepare(qq{
41 SELECT a.id,a.name,a.relationship,s.members,s.score,s.size
42 ,r.resources,r.hidden,r.planets
43 ,(resources/planets)::bigint AS resplanet
44 ,(hidden/planets)::bigint AS hidplanet
45 ,((resources / 300) + (hidden / 100))::bigint AS scoregain
46 ,(score + (resources / 300) + (hidden / 100))::bigint AS nscore
47 ,((resources/planets*scoremem)/300 + (hidden/planets*scoremem)/100)::bigint AS scoregain2
48 ,(score + (resources/planets*scoremem)/300
49 + (hidden/planets*scoremem)/100)::bigint AS nscore2
50 ,((s.size::int8*(1400-tick())*250)/100 + score + (resources/planets*scoremem)/300
51 + (hidden/planets*scoremem)/100)::bigint AS nscore3
52 ,(s.size::int8*(1400-tick())*250)/100 AS scoregain3
53 FROM (SELECT alliance_id AS id,sum(metal+crystal+eonium) AS resources, sum(hidden) AS hidden, count(*) AS planets
54 FROM planets p join planet_scans c ON p.id = c.planet GROUP by alliance_id) r
55 NATURAL JOIN alliances a
56 LEFT OUTER JOIN (SELECT *,LEAST(members,60) AS scoremem FROM alliance_stats
57 WHERE tick = (SELECT max(tick) FROM alliance_stats)) s ON a.id = s.id
62 while (my $alliance = $query->fetchrow_hashref){
63 push @alliances,$alliance;
65 $c->stash(alliances => \@alliances);
75 This library is free software, you can redistribute it and/or modify
76 it under the same terms as Perl itself.