From: Michael Andreen Date: Wed, 26 Aug 2009 20:50:14 +0000 (+0200) Subject: Add links to previous and next galaxy X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=81b74843095bc68e69ad35f2822187fbcae9e2d2 Add links to previous and next galaxy --- diff --git a/lib/NDWeb/Controller/Stats.pm b/lib/NDWeb/Controller/Stats.pm index e28c2ae..4b22736 100644 --- a/lib/NDWeb/Controller/Stats.pm +++ b/lib/NDWeb/Controller/Stats.pm @@ -112,6 +112,21 @@ WHERE g.tick = ( SELECT max(tick) AS max FROM galaxies) $query->execute($x,$y,$z); $c->stash(planets => $query->fetchall_arrayref({}) ); + + $query = $dbh->prepare(q{ +WITH p AS ( + SELECT x,y FROM galaxies + WHERE tick = tick() AND (x <= $1 AND y < $2 OR x < $1) + ORDER BY x DESC, y DESC LIMIT 1 +), n AS ( + SELECT x,y FROM galaxies + WHERE tick = tick() AND (x >= $1 AND y > $2 OR x > $1) + ORDER BY x ASC, y ASC LIMIT 1 +) +TABLE p UNION TABLE n + }); + $query->execute($x,$y); + $c->stash(browse => $query->fetchall_arrayref({}) ); } sub planet : Local { diff --git a/root/src/stats/galaxy.tt2 b/root/src/stats/galaxy.tt2 index b66f74e..6c9e9b8 100644 --- a/root/src/stats/galaxy.tt2 +++ b/root/src/stats/galaxy.tt2 @@ -1,4 +1,7 @@ [% META title = 'Galaxy stats' %] +[% FOR b IN browse %] +[% b.x %]:[% b.y %] +[% END %] [% IF g %] [% PROCESS inc/stats.tt2 %]