diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-01-26 15:31:01 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-01-26 15:31:01 +0100 |
commit | 21234707fcd880cf980de4d31cefe4af951644f0 (patch) | |
tree | 6dd524cf8651a568d1c334705697c24333cfe13e /lib/Travelynx.pm | |
parent | d7c69acf417b5f26c031cb79f36783c86d172e91 (diff) |
add_journey: allow up to 99 journeys per 24 hours
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-x | lib/Travelynx.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index a62cb2e..7a72cc6 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -383,6 +383,27 @@ sub startup { return ( undef, 'Unbekannter Zielbahnhof' ); } + my $daily_journey_count = $db->select( + 'journeys_str', + 'count(*) as count', + { + user_id => $uid, + real_dep_ts => { + -between => [ + $opt{rt_departure}->clone->subtract( days => 1 ) + ->epoch, + $opt{rt_departure}->epoch + ], + }, + } + )->hash->{count}; + + if ( $daily_journey_count >= 100 ) { + return ( undef, +"In den 24 Stunden vor der angegebenen Abfahrtszeit wurden ${daily_journey_count} weitere Fahrten angetreten. Das kann nicht stimmen." + ); + } + my @route = ( [ $dep_station->[1], {}, undef ] ); if ( $opt{route} ) { |