X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FPages%2FCovOp.pm;h=cc2688615274b836d42481228568a284aa1e9670;hb=c26dd7395127b35eef6f219f23ebd6ffc453c2dc;hp=56250ab7ae1a5631eec4d5f2e301af8e819dc0b4;hpb=a074bd17f5e8ba341a22bbfca1da7093b8351774;p=ndwebbie.git diff --git a/NDWeb/Pages/CovOp.pm b/NDWeb/Pages/CovOp.pm index 56250ab..cc26886 100644 --- a/NDWeb/Pages/CovOp.pm +++ b/NDWeb/Pages/CovOp.pm @@ -40,7 +40,7 @@ sub render_body { $self->{TITLE} = 'CovOp Targets'; my $DBH = $self->{DBH}; - return $self->noAccess unless $self->isHC; + return $self->noAccess unless $self->isMember; my $show = q{AND ((planet_status IS NULL OR NOT planet_status IN ('Friendly','NAP')) AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP')))}; $show = '' if defined param('show') && param('show') eq 'all'; @@ -53,31 +53,36 @@ sub render_body { my $where = ''; if (defined param('list') && param('list') eq 'distwhores'){ $list = '&list=distwhores'; - $where = qq{WHERE dists > 0 $show - ORDER BY dists DESC,COALESCE(sec_centres::float/structures*100,0)ASC} + $where = qq{AND distorters > 0 $show + ORDER BY distorters DESC,COALESCE(seccents::float/structures*100,0)ASC} }else{ - $where = qq{WHERE MaxResHack > 130000 + $where = qq{AND MaxResHack > 130000 $show - ORDER BY COALESCE(sec_centres::float/structures*100,0) ASC,MaxResHack DESC,metal+crystal+eonium DESC}; + ORDER BY COALESCE(seccents::float/structures*100,0) ASC,MaxResHack DESC,metal+crystal+eonium DESC}; } - my $query = $DBH->prepare(qq{SELECT id, coords, metal, crystal, eonium, sec_centres::float/structures*100 AS secs, dists, last_covop, username, MaxResHack + my $query = $DBH->prepare(qq{SELECT id, coords, metal, crystal, eonium + , seccents::float/structures*100 AS secs, distorters + , MaxResHack FROM (SELECT p.id,coords(x,y,z), metal,crystal,eonium, - sec_centres,NULLIF(structures,0) AS structures,dists,last_covop, - u.username,max_bank_hack(metal,crystal,eonium,p.value,(SELECT value FROM - current_planet_stats WHERE id = ?)) AS MaxResHack, planet_status, relationship - FROM covop_targets c JOIN current_planet_stats p ON p.id = c.planet - LEFT OUTER JOIN users u ON u.uid = c.covop_by) AS foo - $where}); + seccents,NULLIF(ss.total,0) AS structures,distorters + ,max_bank_hack(metal,crystal,eonium,p.value + ,(SELECT value FROM current_planet_stats WHERE id = ?)) AS MaxResHack + , planet_status, relationship + FROM current_planet_stats p + LEFT OUTER JOIN planet_scans ps ON p.id = ps.planet + LEFT OUTER JOIN structure_scans ss ON p.id = ss.planet + ) AS foo + WHERE (metal IS NOT NULL OR seccents IS NOT NULL) + $where + }); $query->execute($self->{PLANET}); my @targets; - my $i = 0; - while (my ($id,$coords,$metal,$crystal,$eonium,$seccents,$dists,$lastcovop,$user,$max) = $query->fetchrow){ - $i++; - push @targets,{Username => $user, Target => $id, Coords => $coords + while (my ($id,$coords,$metal,$crystal,$eonium,$seccents,$dists,$max) = $query->fetchrow){ + push @targets,{Target => $id, Coords => $coords , Metal => $metal, Crystal => $crystal, Eonium => $eonium, SecCents => $seccents - , Dists => $dists, MaxResHack => $max, LastCovOp => $lastcovop, List => $list, ODD => $i % 2}; + , Dists => $dists, MaxResHack => $max, List => $list}; } $BODY->param(Targets => \@targets); return $BODY;