]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Stats.pm
Fix in case planets happens to be 0
[ndwebbie.git] / lib / NDWeb / Controller / Stats.pm
index 14cd6ed8e4cff987fcfb1a4269e124b910931c25..9379e99c0aa8574835eb86ddee63728bf49dae7a 100644 (file)
@@ -62,7 +62,7 @@ FROM galaxies g
                        GROUP BY raid,p.tick,x,y
                        ) AS a
                        JOIN galaxies g USING (tick,x,y)
-               WHERE a.count::float / g.planets >= 0.5
+               WHERE a.count::float / NULLIF(g.planets,0) >= 0.5
                ORDER BY x,y,tick
        ) AS raid USING (x,y)
 
@@ -299,7 +299,7 @@ GROUP BY tag
        $c->stash(cloud => $cloud->html);
        $c->stash(css => $cloud->css);
 
-       my $query = $dbh->prepare(q{
+       $query = $dbh->prepare(q{
 WITH p AS (SELECT pid, coords(x,y,z) FROM current_planet_stats
 ), t AS (SELECT pid,tag,bool_or(uid = $2) AS own,max(time) AS time
        FROM planet_tags