summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Model/Journeys.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-04-02 15:24:39 +0200
committerDaniel Friesel <derf@finalrewind.org>2022-04-02 15:24:39 +0200
commit5dfbdd864433a01271e8025842b20608146e5152 (patch)
tree835f2b4128761bf82ad9e58ead55b503a314a6e9 /lib/Travelynx/Model/Journeys.pm
parent5cd25d442f01e6159fde7814acac5a5c201a3a6c (diff)
history map: add filter by date
Diffstat (limited to 'lib/Travelynx/Model/Journeys.pm')
-rwxr-xr-xlib/Travelynx/Model/Journeys.pm31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm
index 2e97150..8567d27 100755
--- a/lib/Travelynx/Model/Journeys.pm
+++ b/lib/Travelynx/Model/Journeys.pm
@@ -156,7 +156,7 @@ sub add {
push( @route, [ $station_info->[1], {}, undef ] );
}
else {
- push( @route, [ $station, {}, undef ] );
+ push( @route, [ $station, {}, undef ] );
push( @unknown_stations, $station );
}
}
@@ -519,6 +519,12 @@ sub get {
$where{real_dep_ts}
= { -between => [ $opt{after}->epoch, $opt{before}->epoch, ] };
}
+ elsif ( $opt{after} ) {
+ $where{real_dep_ts} = { '>=', $opt{after}->epoch };
+ }
+ elsif ( $opt{before} ) {
+ $where{real_dep_ts} = { '<=', $opt{before}->epoch };
+ }
if ( $opt{with_polyline} ) {
push( @select, 'polyline' );
@@ -975,9 +981,10 @@ sub get_travel_distance {
for my $station (@polyline) {
#lonlatlonlat
- $distance_polyline
- += $geo->distance_metal( $prev_station->[1],
- $prev_station->[0], $station->[1], $station->[0] );
+ $distance_polyline += $geo->distance_metal(
+ $prev_station->[1], $prev_station->[0],
+ $station->[1], $station->[0]
+ );
$prev_station = $station;
}
@@ -1004,9 +1011,10 @@ sub get_travel_distance {
$to_station_beeline = $station;
}
if ( $#{$prev_station} >= 4 and $#{$station} >= 4 ) {
- $distance_intermediate
- += $geo->distance_metal( $prev_station->[4],
- $prev_station->[3], $station->[4], $station->[3] );
+ $distance_intermediate += $geo->distance_metal(
+ $prev_station->[4], $prev_station->[3],
+ $station->[4], $station->[3]
+ );
}
else {
$skipped++;
@@ -1017,9 +1025,8 @@ sub get_travel_distance {
if ( $from_station_beeline and $to_station_beeline ) {
$distance_beeline = $geo->distance_metal(
- $from_station_beeline->[4],
- $from_station_beeline->[3], $to_station_beeline->[4],
- $to_station_beeline->[3]
+ $from_station_beeline->[4], $from_station_beeline->[3],
+ $to_station_beeline->[4], $to_station_beeline->[3]
);
}
@@ -1120,8 +1127,8 @@ sub get_stats {
}
my $uid = $opt{uid};
- my $db = $opt{db} // $self->{pg}->db;
- my $year = $opt{year} // 0;
+ my $db = $opt{db} // $self->{pg}->db;
+ my $year = $opt{year} // 0;
my $month = $opt{month} // 0;
# Assumption: If the stats cache contains an entry it is up-to-date.