]> ruin.nu Git - ndwebbie.git/commitdiff
Updated covop view to account for extra resources since scan and different sorting
authorMichael Andreen <harv@ruin.nu>
Fri, 20 Feb 2009 16:42:13 +0000 (17:42 +0100)
committerMichael Andreen <harv@ruin.nu>
Fri, 20 Feb 2009 16:42:13 +0000 (17:42 +0100)
lib/NDWeb/Controller/CovOp.pm

index 7b020b045d81a9379204206623331194a38a03fc..1c2a3a4ecff024e057979be05e6e5f80900f8b08 100644 (file)
@@ -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({}));