]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Alliances.pm
Show how many times an alliance has been targeted by us.
[ndwebbie.git] / lib / NDWeb / Controller / Alliances.pm
index efec3dd6f955ca6f58d845f15ffdf7577843533e..8f0b6c67555203131bbcb25b828e7978945eb6a8 100644 (file)
@@ -4,8 +4,6 @@ use strict;
 use warnings;
 use parent 'Catalyst::Controller';
 
-use NDWeb::Include;
-
 =head1 NAME
 
 NDWeb::Controller::Alliances - Catalyst Controller
@@ -95,13 +93,15 @@ sub edit : Local {
        my $ticks = $c->req->param('ticks') || 48;
        $c->stash(showticks => $ticks);
 
-       $query = $dbh->prepare(intelquery q{
-                       o.alliance AS oalliance ,coords(o.x,o.y,o.z) AS ocoords, i.sender
-                       ,t.alliance AS talliance,coords(t.x,t.y,t.z) AS tcoords, i.target
-               },q{NOT ingal AND (o.alliance = $1 OR t.alliance = $1)
-                       AND (i.mission = 'Defend' OR i.mission = 'AllyDef')
-                       AND COALESCE( t.alliance != o.alliance, TRUE)
-                       AND i.tick > (tick() - $2)
+       $query = $dbh->prepare(q{
+SELECT salliance, scoords, sender, talliance, tcoords, target
+       ,mission, tick AS landingtick, eta, amount, ingal, username
+FROM full_intel
+WHERE NOT ingal AND (salliance = $1 OR talliance = $1)
+       AND (mission = 'Defend' OR mission = 'AllyDef')
+       AND COALESCE( talliance <> salliance, TRUE)
+       AND tick > (tick() - $2)
+ORDER BY tick DESC, mission
                });
        $query->execute($a->{name}, $ticks);
        $c->stash(intel => $query->fetchall_arrayref({}) );
@@ -189,12 +189,8 @@ sub hostile : Local {
        }
 
        my $query = $dbh->prepare(q{
-               SELECT s.alliance_id AS id,s.alliance AS name,count(*) AS hostile_count
-FROM calls c 
-       JOIN incomings i ON i.call = c.id
-       JOIN current_planet_stats s ON i.sender = s.id
-WHERE c.landing_tick - i.eta > $1 and c.landing_tick - i.eta < $2
-GROUP BY s.alliance_id,s.alliance
+SELECT aid, alliance, hostile_count, targeted, targeted_raids
+FROM hostile_alliances($1,$2)
 ORDER BY hostile_count DESC
                });
        $query->execute($begintick,$endtick);