From 1d00da86bb5e47fe7a4a5c8b61fef58cfcbe8a9b Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 20 Feb 2009 17:42:13 +0100 Subject: [PATCH] Updated covop view to account for extra resources since scan and different sorting --- lib/NDWeb/Controller/CovOp.pm | 37 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/NDWeb/Controller/CovOp.pm b/lib/NDWeb/Controller/CovOp.pm index 7b020b0..1c2a3a4 100644 --- a/lib/NDWeb/Controller/CovOp.pm +++ b/lib/NDWeb/Controller/CovOp.pm @@ -23,22 +23,28 @@ Catalyst Controller. sub index :Path :Args(0) { my ( $self, $c ) = @_; - $c->stash( where => q{AND max_bank_hack > 60000 - ORDER BY max_bank_hack DESC, hack5 DESC, hack15 DESC, minalert,x,y,z}); + $c->stash( where => q{hack5 > 60000 + ORDER BY hack5 DESC, hack15 DESC, minalert + ,lastcovop NULLS FIRST,pstick DESC, dstick DESC,x,y,z + }); $c->forward('list'); } sub easy : Local { my ( $self, $c ) = @_; - $c->stash( where => qq{AND minalert < 70 - ORDER BY minalert, max_bank_hack DESC, hack5 DESC, hack15 DESC,x,y,z}); + $c->stash( where => q{minalert < 70 + ORDER BY minalert, max_bank_hack DESC, hack5 DESC, hack15 DESC + ,lastcovop NULLS FIRST,pstick DESC, dstick DESC,x,y,z + }); $c->forward('list'); } sub distwhores : Local { my ( $self, $c ) = @_; - $c->stash( where => qq{AND distorters > 0 - ORDER BY distorters DESC, minalert, x,y,z}); + $c->stash( where => q{distorters > 0 + ORDER BY distorters DESC, minalert + ,lastcovop NULLS FIRST,pstick DESC, dstick DESC,x,y,z + }); $c->forward('list'); } @@ -56,15 +62,21 @@ sub list : Private { my ( $self, $c ) = @_; my $dbh = $c->model; - my $query = $dbh->prepare(q{SELECT * - FROM (SELECT p.id,coords(x,y,z),x,y,z,size, metal,crystal,eonium + my $query = $dbh->prepare(q{ + SELECT * FROM ( + SELECT * + ,max_bank_hack(500000,500000,500000,pvalue,cvalue,5) + ,max_bank_hack(metal,crystal,eonium,pvalue,cvalue,5) AS hack5 + ,max_bank_hack(metal,crystal,eonium,pvalue,cvalue,13) AS hack15 + FROM (SELECT p.id,coords(x,y,z),x,y,z,size + ,metal + metal_roids * (tick()-ps.tick) * 125 AS metal + ,crystal + crystal_roids * (tick()-ps.tick) * 125 AS crystal + ,eonium + eonium_roids * (tick()-ps.tick) * 125 AS eonium ,distorters,guards ,covop_alert(seccents,ds.total,size,guards,gov,0) AS minalert ,covop_alert(seccents,ds.total,size,guards,gov,50) AS maxalert - ,max_bank_hack(500000,500000,500000,p.value,c.value,5) - ,max_bank_hack(metal,crystal,eonium,p.value,c.value,5) AS hack5 - ,max_bank_hack(metal,crystal,eonium,p.value,c.value,15) AS hack15 , planet_status, relationship,gov,ps.tick AS pstick, ds.tick AS dstick + , p.value AS pvalue, c.value AS cvalue FROM current_planet_stats p LEFT OUTER JOIN current_planet_scans ps ON p.id = ps.planet LEFT OUTER JOIN current_development_scans ds ON p.id = ds.planet @@ -75,7 +87,8 @@ sub list : Private { WHERE (metal IS NOT NULL OR distorters IS NOT NULL) AND (NOT planet_status IN ('Friendly','NAP')) AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP')) - } . $c->stash->{where}); + ) a + WHERE } . $c->stash->{where}); $query->execute($c->user->planet); $c->stash(targets => $query->fetchall_arrayref({})); -- 2.39.2