1 package NDWeb::Controller::CovOp;
5 use parent 'Catalyst::Controller';
9 NDWeb::Controller::CovOp - Catalyst Controller
24 sub index :Path :Args(0) {
25 my ( $self, $c ) = @_;
26 $c->stash( where => q{hack5 > 60000 AND minalert < 60
27 ORDER BY hack5 DESC, hack13 DESC
28 ,(CASE WHEN tick() - lastcovop < 6 THEN lastcovop ELSE NULL END) NULLS FIRST
29 ,minalert, pstick DESC, dstick DESC,x,y,z
35 my ( $self, $c ) = @_;
36 $c->stash( where => q{minalert < 60
37 ORDER BY minalert, hack5 DESC,lastcovop NULLS FIRST
38 ,hack13 DESC,pstick DESC, dstick DESC,x,y,z
43 sub distwhores : Local {
44 my ( $self, $c ) = @_;
45 $c->stash( where => q{distorters > 0
46 ORDER BY distorters DESC, minalert
47 ,lastcovop NULLS FIRST,pstick DESC, dstick DESC,x,y,z
52 sub marktarget : Local {
53 my ( $self, $c, $target ) = @_;
55 my $update = $dbh->prepare(q{INSERT INTO covop_attacks (uid,pid,tick) VALUES(?,?,tick())});
57 $update->execute($c->user->id,$target);
59 $c->forward('/redirect');
63 my ( $self, $c ) = @_;
66 my $query = $dbh->prepare(q{
69 ,(2*pvalue::float/cvalue) :: Numeric(4,1) AS max_bank_hack
70 ,max_bank_hack(metal,crystal,eonium,pvalue,cvalue,5) AS hack5
71 ,max_bank_hack(metal,crystal,eonium,pvalue,cvalue,13) AS hack13
72 FROM (SELECT pid,coords(x,y,z),x,y,z,size
73 ,metal + metal_roids * (tick()-ps.tick) * 125 AS metal
74 ,crystal + crystal_roids * (tick()-ps.tick) * 125 AS crystal
75 ,eonium + eonium_roids * (tick()-ps.tick) * 125 AS eonium
77 ,covop_alert(seccents,ds.total,size,guards,gov,0) AS minalert
78 ,covop_alert(seccents,ds.total,size,guards,gov,50) AS maxalert
79 , planet_status, relationship,gov,ps.tick AS pstick, ds.tick AS dstick
80 , p.value AS pvalue, c.value AS cvalue
81 FROM current_planet_stats p
82 LEFT OUTER JOIN current_planet_scans ps USING (pid)
83 LEFT OUTER JOIN current_development_scans ds USING (pid)
84 CROSS JOIN (SELECT value FROM current_planet_stats WHERE pid = $1) c
86 LEFT OUTER JOIN (SELECT pid,max(tick) AS lastcovop FROM covop_attacks
87 GROUP BY pid) co USING (pid)
88 WHERE (metal IS NOT NULL OR distorters IS NOT NULL)
89 AND (NOT planet_status IN ('Friendly','NAP'))
90 AND (relationship IS NULL OR NOT relationship IN ('Friendly','NAP'))
92 WHERE } . $c->stash->{where});
93 $query->execute($c->user->planet);
95 $c->stash(targets => $query->fetchall_arrayref({}));
97 $c->stash(template => 'covop/index.tt2');
101 Michael Andreen (harv@ruin.nu)