From f9f06136c85f9634c409b71e18452c358530556e Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 21 Jun 2008 11:59:46 +0200 Subject: [PATCH] Converted rankings --- NDWeb/Pages/AllianceRankings.pm | 107 ------------------ NDWeb/Pages/GalaxyRankings.pm | 106 ------------------ NDWeb/Pages/PlanetRankings.pm | 101 ----------------- database/group_roles.sql | 7 +- lib/NDWeb/Controller/Rankings.pm | 186 +++++++++++++++++++++++++++++++ lib/NDWeb/Include.pm | 9 +- root/lib/site/leftbar.tt2 | 9 +- root/src/rankings/alliances.tt2 | 40 +++++++ root/src/rankings/galaxies.tt2 | 46 ++++++++ root/src/rankings/planets.tt2 | 59 ++++++++++ t/controller_Rankings.t | 10 ++ templates/alliancerankings.tmpl | 37 ------ templates/galaxyrankings.tmpl | 41 ------- templates/planetrankings.tmpl | 49 -------- 14 files changed, 360 insertions(+), 447 deletions(-) delete mode 100644 NDWeb/Pages/AllianceRankings.pm delete mode 100644 NDWeb/Pages/GalaxyRankings.pm delete mode 100644 NDWeb/Pages/PlanetRankings.pm create mode 100644 lib/NDWeb/Controller/Rankings.pm create mode 100644 root/src/rankings/alliances.tt2 create mode 100644 root/src/rankings/galaxies.tt2 create mode 100644 root/src/rankings/planets.tt2 create mode 100644 t/controller_Rankings.t delete mode 100644 templates/alliancerankings.tmpl delete mode 100644 templates/galaxyrankings.tmpl delete mode 100644 templates/planetrankings.tmpl diff --git a/NDWeb/Pages/AllianceRankings.pm b/NDWeb/Pages/AllianceRankings.pm deleted file mode 100644 index 29bb2df..0000000 --- a/NDWeb/Pages/AllianceRankings.pm +++ /dev/null @@ -1,107 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# 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 NDWeb::Pages::AllianceRankings; -use strict; -use warnings FATAL => 'all'; -use CGI qw/:standard/; -use NDWeb::Include; - -use base qw/NDWeb::XMLPage/; - -$NDWeb::Page::PAGES{alliancerankings} = __PACKAGE__; - -sub parse { - #TODO: Need to fix some links first - #if ($uri =~ m{^/[^/]+/(\w+)}){ - # param('order',$1); - #} -} - -sub render_body { - my $self = shift; - my ($BODY) = @_; - $self->{TITLE} = 'Top Alliances'; - my $DBH = $self->{DBH}; - - return $self->noAccess unless $self->isMember; - - my $error = ''; - - $BODY->param(isHC => $self->isHC); - - my $offset = 0; - if (defined param('offset') && param('offset') =~ /^(\d+)$/){ - $offset = $1; - } - $BODY->param(Offset => $offset); - $BODY->param(PrevOffset => $offset - 100); - $BODY->param(NextOffset => $offset + 100); - - my $order = 'scorerank'; - if (defined param('order') && param('order') =~ /^(scorerank|sizerank|members|avgsize|avgscore)$/){ - $order = $1; - } - $BODY->param(Order => $order); - $order .= ' DESC' unless $order =~ /rank$/; - - - #my $extra_columns = ''; - #if ($self->isHC){ - # $extra_columns = ",alliance_status,hit_us, alliance,relationship,nick"; - #} - my $query = $DBH->prepare(qq{SELECT a.name, - size, size_gain, size_gain_day, - score,score_gain,score_gain_day, - avgsize,avgsize_gain,avgsize_gain_day, - avgscore,avgscore_gain,avgscore_gain_day, - sizerank,sizerank_gain,sizerank_gain_day, - scorerank,scorerank_gain,scorerank_gain_day, - members,members_gain,members_gain_day - FROM - ( SELECT id, members,members_gain,members_gain_day, size, score, (size/members) AS avgsize, (score/members) AS avgscore, sizerank, scorerank, size_gain, score_gain, (size_gain/members) AS avgsize_gain, (score_gain/members) AS avgscore_gain, sizerank_gain, scorerank_gain, size_gain_day, score_gain_day, (size_gain_day/members) AS avgsize_gain_day, (score_gain_day/members) AS avgscore_gain_day, sizerank_gain_day, scorerank_gain_day - FROM alliance_stats WHERE tick = (( SELECT max(tick) AS max FROM alliance_stats))) ast - NATURAL JOIN alliances a - ORDER BY $order LIMIT 100 OFFSET ?}); - $query->execute($offset) or $error .= p($DBH->errstr); - my @alliances; - while (my $alliance = $query->fetchrow_hashref){ - for my $type (qw/members size score avgsize avgscore/){ - #$alliance->{$type} = prettyValue($alliance->{$type}); - next unless defined $alliance->{"${type}_gain_day"}; - $alliance->{"${type}img"} = 'stay'; - $alliance->{"${type}img"} = 'up' if $alliance->{"${type}_gain_day"} > 0; - $alliance->{"${type}img"} = 'down' if $alliance->{"${type}_gain_day"} < 0; - if( $type eq 'size' || $type eq 'score'){ - $alliance->{"${type}rankimg"} = 'stay'; - $alliance->{"${type}rankimg"} = 'up' if $alliance->{"${type}rank_gain_day"} < 0; - $alliance->{"${type}rankimg"} = 'down' if $alliance->{"${type}rank_gain_day"} > 0; - } - for my $type ($type,"${type}_gain","${type}_gain_day"){ - $alliance->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 - } - } - push @alliances,$alliance; - } - $BODY->param(Alliances => \@alliances); - $BODY->param(Error => $error); - return $BODY; -} - -1; diff --git a/NDWeb/Pages/GalaxyRankings.pm b/NDWeb/Pages/GalaxyRankings.pm deleted file mode 100644 index 318f4f4..0000000 --- a/NDWeb/Pages/GalaxyRankings.pm +++ /dev/null @@ -1,106 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# 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 NDWeb::Pages::GalaxyRankings; -use strict; -use warnings FATAL => 'all'; -use CGI qw/:standard/; -use NDWeb::Include; - -use base qw/NDWeb::XMLPage/; - -$NDWeb::Page::PAGES{galaxyrankings} = __PACKAGE__; - -sub parse { - #TODO: Need to fix some links first - #if ($uri =~ m{^/[^/]+/(\w+)}){ - # param('order',$1); - #} -} - -sub render_body { - my $self = shift; - my ($BODY) = @_; - $self->{TITLE} = 'Top Galaxies'; - my $DBH = $self->{DBH}; - - return $self->noAccess unless $self->isMember; - - my $error = ''; - - $BODY->param(isHC => $self->isHC); - - my $offset = 0; - if (defined param('offset') && param('offset') =~ /^(\d+)$/){ - $offset = $1; - } - $BODY->param(Offset => $offset); - $BODY->param(PrevOffset => $offset - 100); - $BODY->param(NextOffset => $offset + 100); - - my $order = 'scorerank'; - if (defined param('order') && param('order') =~ /^(scorerank|sizerank|planets|xprank|avgscore)$/){ - $order = $1; - } - $BODY->param(Order => $order); - $order .= ' DESC' unless $order =~ /rank$/; - - - #my $extra_columns = ''; - #if ($self->isHC){ - # $extra_columns = ",galaxy_status,hit_us, galaxy,relationship,nick"; - #} - my $query = $DBH->prepare(qq{SELECT x,y, - size, size_gain, size_gain_day, - score,score_gain,score_gain_day, - value,value_gain,value_gain_day, - xp,xp_gain,xp_gain_day, - sizerank,sizerank_gain,sizerank_gain_day, - scorerank,scorerank_gain,scorerank_gain_day, - valuerank,valuerank_gain,valuerank_gain_day, - xprank,xprank_gain,xprank_gain_day, - planets,planets_gain,planets_gain_day - FROM galaxies g WHERE tick = ( SELECT max(tick) AS max FROM galaxies) - ORDER BY $order LIMIT 100 OFFSET ?}); - $query->execute($offset) or $error .= p($DBH->errstr); - my @galaxies; - while (my $galaxy = $query->fetchrow_hashref){ - for my $type (qw/planets size score xp value/){ - #$galaxy->{$type} = prettyValue($galaxy->{$type}); - next unless defined $galaxy->{"${type}_gain_day"}; - $galaxy->{"${type}img"} = 'stay'; - $galaxy->{"${type}img"} = 'up' if $galaxy->{"${type}_gain_day"} > 0; - $galaxy->{"${type}img"} = 'down' if $galaxy->{"${type}_gain_day"} < 0; - unless( $type eq 'planets'){ - $galaxy->{"${type}rankimg"} = 'stay'; - $galaxy->{"${type}rankimg"} = 'up' if $galaxy->{"${type}rank_gain_day"} < 0; - $galaxy->{"${type}rankimg"} = 'down' if $galaxy->{"${type}rank_gain_day"} > 0; - } - for my $type ($type,"${type}_gain","${type}_gain_day"){ - $galaxy->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 - } - } - push @galaxies,$galaxy; - } - $BODY->param(Galaxies => \@galaxies); - $BODY->param(Error => $error); - return $BODY; -} - -1; diff --git a/NDWeb/Pages/PlanetRankings.pm b/NDWeb/Pages/PlanetRankings.pm deleted file mode 100644 index e744626..0000000 --- a/NDWeb/Pages/PlanetRankings.pm +++ /dev/null @@ -1,101 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# 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 NDWeb::Pages::PlanetRankings; -use strict; -use warnings FATAL => 'all'; -use CGI qw/:standard/; -use NDWeb::Include; - -use base qw/NDWeb::XMLPage/; - -$NDWeb::Page::PAGES{planetrankings} = __PACKAGE__; - -sub parse { - #TODO: Need to fix some links first - #if ($uri =~ m{^/[^/]+/(\w+)}){ - # param('order',$1); - #} -} - -sub render_body { - my $self = shift; - my ($BODY) = @_; - $self->{TITLE} = 'Top planets'; - my $DBH = $self->{DBH}; - - return $self->noAccess unless $self->isMember; - - my $error = ''; - - $BODY->param(isHC => $self->isHC); - - my $offset = 0; - if (defined param('offset') && param('offset') =~ /^(\d+)$/){ - $offset = $1; - } - $BODY->param(Offset => $offset); - $BODY->param(PrevOffset => $offset - 100); - $BODY->param(NextOffset => $offset + 100); - - my $order = 'scorerank'; - if (defined param('order') && param('order') =~ /^(scorerank|sizerank|valuerank|xprank|hit_us)$/){ - $order = $1; - } - $BODY->param(Order => $order); - $order .= ' DESC' if ($order eq 'hit_us'); - - - my $extra_columns = ''; - if ($self->isHC){ - $extra_columns = ",planet_status,hit_us, alliance,relationship,nick"; - } - my $query = $DBH->prepare(qq{SELECT x,y,z,((ruler || ' OF ') || planet) as planet,race, - size, size_gain, size_gain_day, - score,score_gain,score_gain_day, - value,value_gain,value_gain_day, - xp,xp_gain,xp_gain_day, - sizerank,sizerank_gain,sizerank_gain_day, - scorerank,scorerank_gain,scorerank_gain_day, - valuerank,valuerank_gain,valuerank_gain_day, - xprank,xprank_gain,xprank_gain_day - $extra_columns FROM current_planet_stats_full ORDER BY $order LIMIT 100 OFFSET ?}); - $query->execute($offset) or $error .= p($DBH->errstr); - my @planets; - while (my $planet = $query->fetchrow_hashref){ - for my $type (qw/size score value xp/){ - #$planet->{$type} = prettyValue($planet->{$type}); - $planet->{"${type}img"} = 'stay'; - $planet->{"${type}img"} = 'up' if $planet->{"${type}_gain_day"} > 0; - $planet->{"${type}img"} = 'down' if $planet->{"${type}_gain_day"} < 0; - $planet->{"${type}rankimg"} = 'stay'; - $planet->{"${type}rankimg"} = 'up' if $planet->{"${type}rank_gain_day"} < 0; - $planet->{"${type}rankimg"} = 'down' if $planet->{"${type}rank_gain_day"} > 0; - for my $type ($type,"${type}_gain","${type}_gain_day"){ - $planet->{$type} =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; #Add comma for ever 3 digits, i.e. 1000 => 1,000 - } - } - push @planets,$planet; - } - $BODY->param(Planets => \@planets); - $BODY->param(Error => $error); - return $BODY; -} - -1; diff --git a/database/group_roles.sql b/database/group_roles.sql index b6165ab..20efb1f 100644 --- a/database/group_roles.sql +++ b/database/group_roles.sql @@ -1,10 +1,10 @@ CREATE TABLE roles ( - role VARCHAR(20) UNIQUE NOT NULL + role VARCHAR(32) UNIQUE NOT NULL ); CREATE TABLE group_roles ( gid INTEGER REFERENCES groups(gid), - role VARCHAR(20) REFERENCES roles(role) + role VARCHAR(32) REFERENCES roles(role) ); INSERT INTO roles VALUES('member_menu'); @@ -15,6 +15,7 @@ INSERT INTO roles VALUES('intel_menu'); INSERT INTO roles VALUES('attack_menu'); INSERT INTO roles VALUES('no_fleet_update'); INSERT INTO roles VALUES('admin_users'); +INSERT INTO roles VALUES('rankings_planet_intel'); INSERT INTO group_roles (gid,role) VALUES(2,'member_menu'); INSERT INTO group_roles (gid,role) VALUES(2,'attack_menu'); @@ -28,9 +29,11 @@ INSERT INTO group_roles (gid,role) VALUES(1,'bc_menu'); INSERT INTO group_roles (gid,role) VALUES(1,'hc_menu'); INSERT INTO group_roles (gid,role) VALUES(1,'intel_menu'); INSERT INTO group_roles (gid,role) VALUES(1,'admin_users'); +INSERT INTO group_roles (gid,role) VALUES(1,'rankings_planet_intel'); INSERT INTO group_roles (gid,role) VALUES(3,'dc_menu'); INSERT INTO group_roles (gid,role) VALUES(3,'bc_menu'); INSERT INTO group_roles (gid,role) VALUES(3,'hc_menu'); INSERT INTO group_roles (gid,role) VALUES(3,'intel_menu'); INSERT INTO group_roles (gid,role) VALUES(3,'admin_users'); +INSERT INTO group_roles (gid,role) VALUES(3,'rankings_planet_intel'); diff --git a/lib/NDWeb/Controller/Rankings.pm b/lib/NDWeb/Controller/Rankings.pm new file mode 100644 index 0000000..30407c6 --- /dev/null +++ b/lib/NDWeb/Controller/Rankings.pm @@ -0,0 +1,186 @@ +package NDWeb::Controller::Rankings; + +use strict; +use warnings; +use parent 'Catalyst::Controller'; + +use NDWeb::Include; + +=head1 NAME + +NDWeb::Controller::Rankings - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +#sub index :Path :Args(0) { +# my ( $self, $c ) = @_; +# +# $c->response->body('Matched NDWeb::Controller::Rankings in Rankings.'); +#} + +sub planets : Local { + my ( $self, $c, $order, $offset ) = @_; + my $dbh = $c->model; + + my $error = ''; + + $offset = 0 unless $offset; + $c->stash(offset => $offset); + + $c->stash( comma => \&comma_value); + + if (defined $order && $order =~ /^(scorerank|sizerank|valuerank|xprank|hit_us)$/){ + $order = $1; + }else { + $order = 'scorerank'; + } + my $browse = qq{ORDER BY $order DESC LIMIT 100 OFFSET ?}; + if ($order =~ /rank$/){ + $browse = qq{WHERE $order > ? ORDER BY $order ASC LIMIT 100}; + } + $c->stash(order => $order); + + my $extra_columns = ''; + if ($c->check_user_roles(qw/rankings_planet_intel/)){ + $c->stash(extracolumns => 1); + $extra_columns = ",planet_status,hit_us, alliance,relationship,nick"; + } + + my $query = $dbh->prepare(qq{SELECT id,x,y,z,ruler,planet,race, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + value,value_gain,value_gain_day, + xp,xp_gain,xp_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + valuerank,valuerank_gain,valuerank_gain_day, + xprank,xprank_gain,xprank_gain_day + $extra_columns FROM current_planet_stats_full + $browse + }); + $query->execute($offset); + my @planets; + while (my $planet = $query->fetchrow_hashref){ + push @planets,$planet; + } + $c->stash(planets => \@planets); +} + +sub galaxies : Local { + my ( $self, $c, $order, $offset ) = @_; + my $dbh = $c->model; + + my $error = ''; + + $offset = 0 unless $offset; + $c->stash(offset => $offset); + + $c->stash( comma => \&comma_value); + + if (defined $order && $order =~ /^(scorerank|sizerank|valuerank|xprank|planets)$/){ + $order = $1; + }else{ + $order = 'scorerank'; + } + $c->stash(order => $order); + + my $browse = qq{ORDER BY $order DESC LIMIT 100 OFFSET ?}; + if ($order =~ /rank$/){ + $browse = qq{AND $order > ? ORDER BY $order ASC LIMIT 100}; + } + my $query = $dbh->prepare(qq{SELECT x,y, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + value,value_gain,value_gain_day, + xp,xp_gain,xp_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + valuerank,valuerank_gain,valuerank_gain_day, + xprank,xprank_gain,xprank_gain_day, + planets,planets_gain,planets_gain_day + FROM galaxies g + WHERE tick = ( SELECT max(tick) AS max FROM galaxies) + $browse + }); + $query->execute($offset); + my @galaxies; + while (my $galaxy = $query->fetchrow_hashref){ + push @galaxies,$galaxy; + } + $c->stash(galaxies => \@galaxies); +} + + +sub alliances : Local { + my ( $self, $c, $order, $offset ) = @_; + my $dbh = $c->model; + + my $error = ''; + + $offset = 0 unless $offset; + $c->stash(offset => $offset); + + $c->stash( comma => \&comma_value); + + if (defined $order && $order =~ /^(scorerank|sizerank|valuerank|xprank|avgsize|avgscore|members)$/){ + $order = $1; + }else{ + $order = 'scorerank'; + } + $c->stash(order => $order); + + my $browse = qq{ORDER BY $order DESC LIMIT 100 OFFSET ?}; + if ($order =~ /rank$/){ + $browse = qq{WHERE $order > ? ORDER BY $order ASC LIMIT 100}; + } + my $query = $dbh->prepare(qq{SELECT a.name,a.id, + size, size_gain, size_gain_day, + score,score_gain,score_gain_day, + avgsize,avgsize_gain,avgsize_gain_day, + avgscore,avgscore_gain,avgscore_gain_day, + sizerank,sizerank_gain,sizerank_gain_day, + scorerank,scorerank_gain,scorerank_gain_day, + members,members_gain,members_gain_day + FROM ( SELECT *, (size/members) AS avgsize + ,(score/scoremem) AS avgscore + ,(size_gain/members) AS avgsize_gain + ,(score_gain/scoremem) AS avgscore_gain + ,(size_gain_day/members) AS avgsize_gain_day + ,(score_gain_day/scoremem) AS avgscore_gain_day + FROM (SELECT *,(CASE WHEN members > 60 THEN 60 ELSE members END) AS scoremem + FROM alliance_stats WHERE + tick = ( SELECT max(tick) AS max FROM alliance_stats)) ast2 + ) ast + NATURAL JOIN alliances a + $browse + }); + $query->execute($offset); + my @alliances; + while (my $alliance = $query->fetchrow_hashref){ + push @alliances,$alliance; + } + $c->stash(alliances => \@alliances); +} + +=head1 AUTHOR + +Michael Andreen (harv@ruin.nu) + +=head1 LICENSE + +GPL 2.0, or later + +=cut + +1; diff --git a/lib/NDWeb/Include.pm b/lib/NDWeb/Include.pm index ff5a882..4b94597 100644 --- a/lib/NDWeb/Include.pm +++ b/lib/NDWeb/Include.pm @@ -27,12 +27,19 @@ use CGI qw/:standard/; our @ISA = qw/Exporter/; our @EXPORT = qw/parseMarkup min max - alliances intelquery html_escape/; + alliances intelquery html_escape + comma_value/; sub html_escape($) { return CGI::escapeHTML @_; } +sub comma_value ($) { + my ($v) = @_; + $v =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; + return $v; +} + sub parseMarkup ($) { my ($text) = @_; diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index e69075e..a456fb9 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -1,5 +1,6 @@

Tick: [% game.tick %]

+ [% IF c.check_user_roles("member_menu") %] [% IF user.attacker %]

Member menu

@@ -27,9 +33,6 @@
  • Launch confirmation
  • CovOp targets
  • Distwhores
  • -
  • Planet Rankings
  • -
  • Alliance Rankings
  • -
  • Galaxy Rankings
  • Request defense
  • [% ELSE %] diff --git a/root/src/rankings/alliances.tt2 b/root/src/rankings/alliances.tt2 new file mode 100644 index 0000000..8c95a4c --- /dev/null +++ b/root/src/rankings/alliances.tt2 @@ -0,0 +1,40 @@ +[% META title = 'Alliance Rankings' %] +

    Previous 100 + Next 100 +

    + + + + + + + + + + + + + +[% FOR a IN alliances %] + + [% a.sizerankimg = (a.sizerank_gain_day == 0 ? 'stay' : (a.sizerank_gain_day < 0 ? 'up' : 'down')) %] + + [% a.scorerankimg = (a.scorerank_gain_day == 0 ? 'stay' : (a.scorerank_gain_day < 0 ? 'up' : 'down')) %] + + + [% a.membersimg = (a.members_gain_day == 0 ? 'stay' : (a.members_gain_day > 0 ? 'up' : 'down')) %] + + [% a.sizeimg = (a.size_gain_day == 0 ? 'stay' : (a.size_gain_day > 0 ? 'up' : 'down')) %] + + [% a.scoreimg = (a.score_gain_day == 0 ? 'stay' : (a.score_gain_day > 0 ? 'up' : 'down')) %] + + [% a.avgsizeimg = (a.avgsize_gain_day == 0 ? 'stay' : (a.avgsize_gain_day > 0 ? 'up' : 'down')) %] + + [% a.avgscoreimg = (a.avgscore_gain_day == 0 ? 'stay' : (a.avgscore_gain_day > 0 ? 'up' : 'down')) %] + + +[% END %] +
    Rank
    SizeScoreNameMembersSizeScoreAvg SizeAvg Score
    [% a.sizerank %] [% a.sizerankimg %] [% a.scorerank %] [% a.scorerankimg %] [% a.name %][% a.members %] [% a.membersimg %] [% comma(a.size) %] [% a.sizeimg %] [% comma(a.score) %] [% a.scoreimg %] [% comma(a.avgsize) %] [% a.avgsizeimg %] [% comma(a.avgscore) %] [% a.avgscoreimg %]
    +

    Previous 100 + Next 100 +

    diff --git a/root/src/rankings/galaxies.tt2 b/root/src/rankings/galaxies.tt2 new file mode 100644 index 0000000..869a3e6 --- /dev/null +++ b/root/src/rankings/galaxies.tt2 @@ -0,0 +1,46 @@ +[% META title = 'Galaxy Rankings' %] +

    Previous 100 + Next 100 +

    + + + + + + + + + + + + + + + + [% FOR g IN galaxies %] + + [% g.sizerankimg = (g.sizerank_gain_day == 0 ? 'stay' : (g.sizerank_gain_day < 0 ? 'up' : 'down')) %] + + [% g.scorerankimg = (g.scorerank_gain_day == 0 ? 'stay' : (g.scorerank_gain_day < 0 ? 'up' : 'down')) %] + + [% g.valuerankimg = (g.valuerank_gain_day == 0 ? 'stay' : (g.valuerank_gain_day < 0 ? 'up' : 'down')) %] + + [% g.xprankimg = (g.xprank_gain_day == 0 ? 'stay' : (g.xprank_gain_day < 0 ? 'up' : 'down')) %] + + + [% g.planetsimg = (g.planets_gain_day == 0 ? 'stay' : (g.planets_gain_day > 0 ? 'up' : 'down')) %] + + [% g.sizeimg = (g.size_gain_day == 0 ? 'stay' : (g.size_gain_day > 0 ? 'up' : 'down')) %] + + [% g.scoreimg = (g.score_gain_day == 0 ? 'stay' : (g.score_gain_day > 0 ? 'up' : 'down')) %] + + [% g.valueimg = (g.value_gain_day == 0 ? 'stay' : (g.value_gain_day > 0 ? 'up' : 'down')) %] + + [% g.xpimg = (g.xp_gain_day == 0 ? 'stay' : (g.xp_gain_day > 0 ? 'up' : 'down')) %] + + +[% END %] +
    Rank
    SizeScoreValueXPCoordsPlanetsSizeScoreValueXP
    [% g.sizerank %] [% g.sizerankimg %] [% g.scorerank %] [% g.scorerankimg %] [% g.valuerank %] [% g.valuerankimg %] [% g.xprank %] [% g.xprankimg %] [% g.x %]:[% g.y %][% comma(g.planets) %] [% g.planetsimg %] [% comma(g.size) %] [% g.sizeimg %] [% comma(g.score) %] [% g.scoreimg %] [% comma(g.value) %] [% g.valueimg %] [% comma(g.xp) %] [% g.xpimg %]
    +

    Previous 100 + Next 100 +

    diff --git a/root/src/rankings/planets.tt2 b/root/src/rankings/planets.tt2 new file mode 100644 index 0000000..a631abe --- /dev/null +++ b/root/src/rankings/planets.tt2 @@ -0,0 +1,59 @@ +[% META title = 'Planet Rankings' %] +

    Previous 100 + Next 100 +

    + + + + + + + + + + + + + +[% IF extracolumns %] + + + +[% END %] + +[% FOR p IN planets %] + + [% p.sizerankimg = (p.sizerank_gain_day == 0 ? 'stay' : (p.sizerank_gain_day < 0 ? 'up' : 'down')) %] + + [% p.scorerankimg = (p.scorerank_gain_day == 0 ? 'stay' : (p.scorerank_gain_day < 0 ? 'up' : 'down')) %] + + [% p.valuerankimg = (p.valuerank_gain_day == 0 ? 'stay' : (p.valuerank_gain_day < 0 ? 'up' : 'down')) %] + + [% p.xprankimg = (p.xprank_gain_day == 0 ? 'stay' : (p.xprank_gain_day < 0 ? 'up' : 'down')) %] + + + + + + + + [% p.sizeimg = (p.size_gain_day == 0 ? 'stay' : (p.size_gain_day > 0 ? 'up' : 'down')) %] + + [% p.scoreimg = (p.score_gain_day == 0 ? 'stay' : (p.score_gain_day > 0 ? 'up' : 'down')) %] + + [% p.valueimg = (p.value_gain_day == 0 ? 'stay' : (p.value_gain_day > 0 ? 'up' : 'down')) %] + + [% p.xpimg = (p.xp_gain_day == 0 ? 'stay' : (p.xp_gain_day > 0 ? 'up' : 'down')) %] + + + [% IF extracolumns %] + + + + [% END %] + +[% END %] +
    Rank
    SizeScoreValueXPXYZPlanetRaceSizeScoreValueXPNickHit usAlliance
    [% p.sizerank %] [% p.sizerankimg %] [% p.scorerank %] [% p.scorerankimg %] [% p.valuerank %] [% p.valuerankimg %] [% p.xprank %] [% p.xprankimg %] [% p.x %] [% p.y %][% p.z %][% p.ruler %] OF [% p.planet %][% p.race %][% comma(p.size) %] [% p.sizeimg %] [% comma(p.score) %] [% p.scoreimg %] [% comma(p.value) %] [% p.valueimg %] [% comma(p.xp) %] [% p.xpimg %] [% p.nick %]([% p.planet_stats %])[% p.hit_us %][% p.alliance %]
    +

    Previous 100 + Next 100 +

    diff --git a/t/controller_Rankings.t b/t/controller_Rankings.t new file mode 100644 index 0000000..bde6b91 --- /dev/null +++ b/t/controller_Rankings.t @@ -0,0 +1,10 @@ +use strict; +use warnings; +use Test::More tests => 3; + +BEGIN { use_ok 'Catalyst::Test', 'NDWeb' } +BEGIN { use_ok 'NDWeb::Controller::Rankings' } + +ok( request('/rankings')->is_success, 'Request should succeed' ); + + diff --git a/templates/alliancerankings.tmpl b/templates/alliancerankings.tmpl deleted file mode 100644 index a44bbf1..0000000 --- a/templates/alliancerankings.tmpl +++ /dev/null @@ -1,37 +0,0 @@ - -

    Previous 100 - Next 100

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Rank
    SizeScoreNameMembersSizeScoreAvg SizeAvg Score
    <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=MembersImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=AvgSizeImg> <TMPL_VAR NAME=AvgScoreImg>
    -

    Previous 100 - Next 100

    diff --git a/templates/galaxyrankings.tmpl b/templates/galaxyrankings.tmpl deleted file mode 100644 index d7eb4e4..0000000 --- a/templates/galaxyrankings.tmpl +++ /dev/null @@ -1,41 +0,0 @@ - -

    Previous 100 - Next 100

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Rank
    SizeScoreValueXPCoordsPlanetsSizeScoreValueXP
    <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> : <TMPL_VAR NAME=PlanetsImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg>
    -

    Previous 100 - Next 100

    diff --git a/templates/planetrankings.tmpl b/templates/planetrankings.tmpl deleted file mode 100644 index 8a71486..0000000 --- a/templates/planetrankings.tmpl +++ /dev/null @@ -1,49 +0,0 @@ - -

    Previous 100 - Next 100

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Rank
    SizeScoreValueXPXYZPlanetRaceSizeScoreValueXPNickHit usAlliance
    <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> <TMPL_VAR NAME=SizeImg> <TMPL_VAR NAME=ScoreImg> <TMPL_VAR NAME=ValueImg> <TMPL_VAR NAME=XPImg> ()
    -

    Previous 100 - Next 100

    -- 2.39.2