From 094d5ccf7e3a7b74d33a7b0db16f37e68d86590c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 13 Jan 2014 13:41:54 +0100 Subject: db-iris: -od: only show most recent delay reason. use -oD for all --- lib/Travel/Status/DE/IRIS/Result.pm | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index c3dd8aa..58a3a99 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -173,6 +173,25 @@ sub destination { return $self->route_end; } +sub delay_messages { + my ($self) = @_; + + my $strp = DateTime::Format::Strptime->new( + pattern => '%y%m%d%H%M', + time_zone => 'Europe/Berlin', + ); + + my @keys = sort keys %{ $self->{messages} }; + my @msgs + = uniq( grep { $_->[1] eq 'd' } map { $self->{messages}{$_} } @keys ); + + my @ret = map { + [ $strp->parse_datetime( $_->[0] ), $self->translate_msg( $_->[2] ) ] + } @msgs; + + return @ret; +} + sub messages { my ($self) = @_; @@ -181,10 +200,13 @@ sub messages { time_zone => 'Europe/Berlin', ); - my @messages = sort keys %{ $self->{messages } }; - my @ret = map { [ $strp->parse_datetime($self->{messages}->{$_}->[0]), - $self->translate_msg($self->{messages}->{$_}->[2]) ] } - @messages; + my @messages = sort keys %{ $self->{messages} }; + my @ret = map { + [ + $strp->parse_datetime( $self->{messages}->{$_}->[0] ), + $self->translate_msg( $self->{messages}->{$_}->[2] ) + ] + } @messages; return @ret; } -- cgit v1.2.3