]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Intel.pm
Added page to list def channels and alliance for planets
[ndwebbie.git] / lib / NDWeb / Controller / Intel.pm
index 535ca28bbf0a4d7109796df30001a2750416895e..bbdf0f749ad461fb16fd0ffaa1101569ddf60105 100644 (file)
@@ -2,6 +2,7 @@ package NDWeb::Controller::Intel;
 
 use strict;
 use warnings;
+use feature ':5.10';
 use parent 'Catalyst::Controller';
 
 use NDWeb::Include;
@@ -97,6 +98,27 @@ sub planet : Local {
 
 }
 
+sub channels : Local {
+       my ( $self, $c, $order ) = @_;
+       my $dbh = $c->model;
+
+       if ($order ~~ /(alliance|channel)/){
+               $order = "lower($1) ASC";
+       }elsif ($order ~~ /(coords)/){
+               $order = "x,y,z";
+       }else{
+               $order = 'lower(channel)';
+       }
+
+       my $query = $dbh->prepare(q{
+SELECT id,coords(x,y,z),nick,channel,alliance FROM current_planet_stats
+WHERE channel <> '' and channel IS NOT NULL
+ORDER BY } . $order
+       );
+       $query->execute;
+       $c->stash(planets => $query->fetchall_arrayref({}) );
+}
+
 sub postplanetcomment : Local {
        my ($self, $c, $p) = @_;