Commit 683a1fb7 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

db-iris: add some wing support. there's at least one major bug still present

(sometimes, departure_wings contains duplicate entries)
parent d629ad66
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -309,7 +309,8 @@ for my $d ( $status->results() ) {
	if (   ( $filter_via and not( first { $_ =~ m{$filter_via}io } @via ) )
		or ( @grep_class and none { $_ ~~ \@grep_class } $d->classes )
		or ( @grep_platform and not( $d->platform ~~ \@grep_platform ) )
		or ( @grep_type and not( $d->type ~~ \@grep_type ) ) )
		or ( @grep_type     and not( $d->type     ~~ \@grep_type ) )
		or $d->is_wing )
	{
		next;
	}
@@ -369,6 +370,23 @@ for my $d ( $status->results() ) {
			$d->route_end, $platformstr // q{}, $d
		]
	);

	for my $wing ( $d->departure_wings ) {
		push(
			@output,
			[
				'' . '' x ( length($timestr) - 1 ),
				$wing->train,
				$edata{route} ? join( q{  }, $wing->route_interesting ) : q{},
				$wing->route_end,
				$platformstr // q{},
				$wing
			]
		);
	}
	if ( $d->departure_wings ) {
		$output[-1][0] = '' . '' x ( length($timestr) - 1 );
	}
}

display_result(@output);
+4 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ my %translation = (
);

Travel::Status::DE::IRIS::Result->mk_ro_accessors(
	qw(arrival classes date datetime delay departure is_cancelled is_transfer
	qw(arrival classes date datetime delay departure is_cancelled is_transfer is_wing
	  line_no train_no_transfer old_train_id old_train_no platform raw_id
	  realtime_xml route_start route_end sched_arrival sched_departure
	  sched_platform sched_route_start sched_route_end start stop_no time
@@ -115,6 +115,7 @@ sub new {
	my ( $train_id, $start_ts, $stop_no ) = split( /.\K-/, $opt{raw_id} );

	$ref->{wing_id} = "${train_id}-${start_ts}";
	$ref->{is_wing} = 0;
	$train_id =~ s{^-}{};

	$ref->{start} = $strp->parse_datetime($start_ts);
@@ -328,6 +329,7 @@ sub set_tl {
sub add_arrival_wingref {
	my ( $self, $ref ) = @_;

	$ref->{is_wing} = 1;
	weaken($ref);
	push( @{ $self->{arrival_wings} }, $ref );
}
@@ -335,6 +337,7 @@ sub add_arrival_wingref {
sub add_departure_wingref {
	my ( $self, $ref ) = @_;

	$ref->{is_wing} = 1;
	weaken($ref);
	push( @{ $self->{departure_wings} }, $ref );
}