summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-16 15:59:37 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-16 15:59:37 +0100
commit808ec8a3f00f7372d28e3b4e436a77bdeec0dddc (patch)
tree5ecab9a0ed73c6812a65a1f00fb276e8cd169302 /index.pl
parent60e27adda5e3a2ebfe4c46707411e825bafa49de (diff)
add limit option to limit number of returned results
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl4
1 files changed, 4 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index d05ca7c..3e6332f 100644
--- a/index.pl
+++ b/index.pl
@@ -518,6 +518,10 @@ sub handle_request {
@results = grep { result_has_train_type( $_, @train_types ) } @results;
}
+ if ( $limit and $limit =~ m{ ^ \d+ $ }x ) {
+ splice( @results, $limit );
+ }
+
for my $result (@results) {
my $platform = ( split( qr{ }, $result->platform // '' ) )[0];
my $delay = $result->delay;