summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-10-27 07:32:37 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-10-27 07:32:37 +0200
commitddbe902384d0a33bc4aa4f57ccdb274cd90a9101 (patch)
tree1816d1100301fafadb00087bef02300e244fdfb8
parent95cbc500ae6841ff552a7b299c127c0754fb3a23 (diff)
departures: show next / most recent departures first
-rwxr-xr-xindex.pl11
1 files changed, 7 insertions, 4 deletions
diff --git a/index.pl b/index.pl
index 90fb660..3809d20 100755
--- a/index.pl
+++ b/index.pl
@@ -213,7 +213,7 @@ sub get_departures {
lookbehind => 20,
datetime => DateTime->now( time_zone => 'Europe/Berlin' )
->subtract( minutes => $lookbehind ),
- lookahead => $lookbehind + 20,
+ lookahead => $lookbehind + 10,
);
return {
results => [ $status->results ],
@@ -700,10 +700,13 @@ get '/*station' => sub {
$self->render( 'landingpage', error => $status->{errstr} );
}
else {
- my @results = sort { $a->line cmp $b->line } @{ $status->{results} };
-
# You can't check into a train which terminates here
- @results = grep { $_->departure } @results;
+ my @results = grep { $_->departure } @{ $status->{results} };
+
+ @results = map { $_->[0] }
+ sort { $b->[1] <=> $a->[1] }
+ map { [$_, $_->sched_departure->epoch // $_->departure->epoch] } @results;
+
$self->render(
'departures',
ds100 => $status->{station_ds100},