1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package ND::Web::Pages::DefLeeches;
22 use warnings FATAL => 'all';
23 use CGI qw/:standard/;
26 use base qw/ND::Web::XMLPage/;
28 $ND::Web::Page::PAGES{defLeeches} = __PACKAGE__;
34 $self->{TITLE} = 'Def Leeches';
35 my $DBH = $self->{DBH};
37 return $self->noAccess unless $self->isDC;
39 my $query = $DBH->prepare(q{SELECT username,defense_points,count(id) AS calls, SUM(fleets) AS fleets, SUM(recalled) AS recalled
40 FROM (SELECT username,defense_points,c.id,count(f.target) AS fleets, count(NULLIF(f.landing_tick + f.eta -1 = f.back,TRUE)) AS recalled
41 FROM users u JOIN calls c ON c.member = u.uid LEFT OUTER JOIN fleets f ON u.planet = f.target AND c.landing_tick = f.landing_tick
42 WHERE (f.mission = 'Defend') OR f.target IS NULL
43 GROUP BY username,defense_points,c.id
45 GROUP BY username,defense_points ORDER BY fleets DESC, defense_points
51 while ( my $member = $query->fetchrow_hashref){
52 $member->{ODD} = $i++ % 2;
53 push @members,$member;
55 $BODY->param(Members => \@members);