X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FIntel.pm;h=bafea58ea8be45ad64da1f5450990e5b3193ad52;hp=015fe339d6b9ce1ed1672ccca0869dd4fe2bb589;hb=07aec9f5f20e4a605d65bbe2337a05663c0b16e7;hpb=208f038007b693c71734ee3c4bbee3ef7dc43cef diff --git a/lib/NDWeb/Controller/Intel.pm b/lib/NDWeb/Controller/Intel.pm index 015fe33..bafea58 100644 --- a/lib/NDWeb/Controller/Intel.pm +++ b/lib/NDWeb/Controller/Intel.pm @@ -31,13 +31,14 @@ sub index :Path : Args(0) { my $ticks = $c->req->param('ticks') || 48; $c->stash(showticks => $ticks); - my $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 ((COALESCE( t.alliance != o.alliance,TRUE) AND (i.mission = 'Defend' OR i.mission = 'AllyDef' )) - OR ( t.alliance = o.alliance AND i.mission = 'Attack')) - AND i.tick > (tick() - $1) + my $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 tick > (tick() - $1) + AND ((COALESCE( talliance <> salliance,TRUE) AND (mission = 'Defend' OR mission = 'AllyDef' )) + OR ( talliance = salliance AND mission = 'Attack')) +ORDER BY tick DESC, mission }); $query->execute($ticks); $c->stash(intel => $query->fetchall_arrayref({}) ); @@ -82,15 +83,23 @@ sub planet : Local { $c->stash(govs => ["","Feu", "Dic", "Dem","Uni"]); $c->stash(planetstatus => ["","Friendly", "NAP", "Hostile"]); - $query = $dbh->prepare(intelquery q{i.sender - ,o.alliance AS oalliance,coords(o.x,o.y,o.z) AS ocoords - },q{i.target = $1 AND i.tick > (tick() - $2)}); + $query = $dbh->prepare(q{ +SELECT salliance, scoords, sender + ,mission, tick AS landingtick, eta, amount, ingal, username +FROM full_intel +WHERE target = $1 AND tick > (tick() - $2) +ORDER BY tick DESC, mission + }); $query->execute($id,$ticks); $c->stash(incoming => $query->fetchall_arrayref({}) ); - $query = $dbh->prepare(intelquery q{i.target - ,t.alliance AS talliance,coords(t.x,t.y,t.z) AS tcoords - },q{i.sender = $1 AND i.tick > (tick() - $2)}); + $query = $dbh->prepare(q{ +SELECT talliance, tcoords, target + ,mission, tick AS landingtick, eta, amount, ingal, username +FROM full_intel +WHERE sender = $1 AND tick > (tick() - $2) +ORDER BY tick DESC, mission + }); $query->execute($id,$ticks); $c->stash(outgoing => $query->fetchall_arrayref({}) );