From 81b74843095bc68e69ad35f2822187fbcae9e2d2 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 26 Aug 2009 22:50:14 +0200 Subject: [PATCH] Add links to previous and next galaxy --- lib/NDWeb/Controller/Stats.pm | 15 +++++++++++++++ root/src/stats/galaxy.tt2 | 3 +++ 2 files changed, 18 insertions(+) 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 %]
-- 2.39.2