]> ruin.nu Git - ndwebbie.git/commitdiff
def leeches
authorMichael Andreen <harv@ruin.nu>
Wed, 16 May 2007 17:30:01 +0000 (17:30 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 16 May 2007 17:30:01 +0000 (17:30 +0000)
ND/Web/Pages/DefLeeches.pm [new file with mode: 0644]
startup.pl
templates/defLeeches.tmpl [new file with mode: 0644]
templates/skel.tmpl

diff --git a/ND/Web/Pages/DefLeeches.pm b/ND/Web/Pages/DefLeeches.pm
new file mode 100644 (file)
index 0000000..aa921b7
--- /dev/null
@@ -0,0 +1,59 @@
+#**************************************************************************
+#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
+#                                                                         *
+#   This program is free software; you can redistribute it and/or modify  *
+#   it under the terms of the GNU General Public License as published by  *
+#   the Free Software Foundation; either version 2 of the License, or     *
+#   (at your option) any later version.                                   *
+#                                                                         *
+#   This program is distributed in the hope that it will be useful,       *
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+#   GNU General Public License for more details.                          *
+#                                                                         *
+#   You should have received a copy of the GNU General Public License     *
+#   along with this program; if not, write to the                         *
+#   Free Software Foundation, Inc.,                                       *
+#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+#**************************************************************************/
+
+package ND::Web::Pages::DefLeeches;
+use strict;
+use warnings FATAL => 'all';
+use CGI qw/:standard/;
+use ND::Web::Include;
+
+use base qw/ND::Web::XMLPage/;
+
+$ND::Web::Page::PAGES{defLeeches} = __PACKAGE__;
+
+
+sub render_body {
+       my $self = shift;
+       my ($BODY) = @_;
+       $self->{TITLE} = 'Def Leeches';
+       my $DBH = $self->{DBH};
+
+       return $self->noAccess unless $self->isHC;
+
+       my $query = $DBH->prepare(q{SELECT username,defense_points,count(id) AS calls, SUM(fleets) AS fleets, SUM(recalled) AS recalled
+               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
+                       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
+                       WHERE (f.mission = 'Defend') OR f.target IS NULL
+                       GROUP BY username,defense_points,c.id
+                       ) d
+               GROUP BY username,defense_points ORDER BY fleets DESC
+               });
+       $query->execute;
+
+       my @members;
+       my $i = 0;
+       while ( my $member = $query->fetchrow_hashref){
+               $member->{ODD} = $i++ % 2;
+               push @members,$member;
+       }
+       $BODY->param(Members => \@members);
+       return $BODY;
+}
+
+1;
index 663c62155bf7d74c6274f6c5124fc27e4170cbc9..52e56ec5bba7b275e12dfcd378d90dd10eb52b6b 100644 (file)
@@ -55,6 +55,7 @@ use ND::Web::Pages::HostileAlliances;
 use ND::Web::Pages::AllianceRankings;
 use ND::Web::Pages::GalaxyRankings;
 use ND::Web::Pages::TargetList;
+use ND::Web::Pages::DefLeeches;
 
 
 
diff --git a/templates/defLeeches.tmpl b/templates/defLeeches.tmpl
new file mode 100644 (file)
index 0000000..b8744e2
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- <TMPL_VAR NAME=Page> -->
+<table>
+       <tr>
+       <th>User</th>
+       <th>Def Points</th>
+       <th>Def Missions</th>
+       <th>Recalled missions</th>
+       <th>Calls</th>
+       </tr>
+       <TMPL_LOOP Members>
+       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+       <td><TMPL_VAR NAME=Username></td>
+       <td><TMPL_VAR NAME=Defense_Points></td>
+       <td><TMPL_VAR NAME=Fleets></td>
+       <td><TMPL_VAR NAME=Recalled></td>
+       <td><TMPL_VAR NAME=Calls></td>
+       </tr>
+       </TMPL_LOOP>
+</table>
index 2be8aee51facd9f60d7330e80af4ff1ddc792116..d345c0e52cf02c5e9a1c1f0a609385622f62a474 100644 (file)
@@ -64,6 +64,7 @@
        <p>HC menu</p>
        <ul class="linkbar">
                <li><a href="/users">List users</a></li>
+               <li><a href="/defLeeches">Def Leeches</a></li>
                <li><a href="/intel">Intel</a></li>
                <li><a href="/alliances">Alliances</a></li>
                <li><a href="/hostileAlliances">Hostile Alliances</a></li>