diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-04-03 20:25:28 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-04-03 20:25:28 +0200 |
commit | 4e1d17e14589f5f41910a9e0cc28a9431230f6e4 (patch) | |
tree | 12775eb2f76694ff60814c8fb7d91d7abe0320cd | |
parent | bc642114e5f32158fe9687e4325709882e313cbb (diff) |
individuallist: add messages per departure
-rw-r--r-- | index.pl | 27 | ||||
-rw-r--r-- | templates/individuallist.html.ep | 9 |
2 files changed, 32 insertions, 4 deletions
@@ -663,6 +663,7 @@ get '/individual' => sub { my $order_param = $self->param('order_by') || 'scheduled_time.d'; my $order; + my %translation = Travel::Status::DE::IRIS::Result::dump_message_codes(); my ( $filter, $filter_clause ) = $self->parse_filter_args; my $dbh = $self->app->dbh; $where_clause .= $filter_clause; @@ -678,7 +679,8 @@ get '/individual' => sub { $where_clause .= ' and delay is not null'; } - my $res = $self->app->dbh->selectall_arrayref( + my $messages = []; + my $res = $self->app->dbh->selectall_arrayref( qq{ select station_codes.name, scheduled_time, delay, is_canceled, stations.name, train_types.name, train_no, lines.name, platform @@ -693,10 +695,31 @@ get '/individual' => sub { } ); - for my $row ( @{$res} ) { + for my $msg ( 1 .. 99 ) { + my $msg_res = $self->app->dbh->selectall_arrayref( + qq{ + select (msgtable.train_id is not null) + from departures + left outer join msg_$msg as msgtable + using (scheduled_time, train_id) + where $where_clause + order by $order + limit 1000 + } + ); + for my $i ( 0 .. $#{$res} ) { + if ( $msg_res->[$i][0] ) { + push( @{ $messages->[$i] }, $translation{$msg} // $msg ); + } + } + } + + for my $i ( 0 .. $#{$res} ) { + my $row = $res->[$i]; $row->[0] = Travel::Status::DE::IRIS::Stations::get_station( $row->[0] )->[1]; $row->[4] = decode( 'utf-8', $row->[4] ); + push( @{$row}, $messages->[$i] ); } $self->render( diff --git a/templates/individuallist.html.ep b/templates/individuallist.html.ep index b7b7535..f7912b2 100644 --- a/templates/individuallist.html.ep +++ b/templates/individuallist.html.ep @@ -8,9 +8,9 @@ Keine Daten mit diesen Parametern gefunden. % else { <div class="individuallist"> <table> -<tr><th>Bahnhof</th><th>Zeit</th><th>Zug</th><th>Nummer</th><th>Richtung</th></tr> +<tr><th>Bahnhof</th><th>Zeit</th><th>Zug</th><th>Nummer</th><th>Richtung</th><th>Meldungen</th></tr> % for my $entry (@{ stash('list') // [] }) { -% my ($station, $time, $delay, $canceled, $dest, $train_type, $train_no, $line_no, $platform) = @{$entry}; +% my ($station, $time, $delay, $canceled, $dest, $train_type, $train_no, $line_no, $platform, $messages) = @{$entry}; <tr> <td class="station"> %= $station @@ -42,6 +42,11 @@ Keine Daten mit diesen Parametern gefunden. <td class="destination"> %= $dest </td> +<td class="messages"> +% for my $msg (@{$messages // []}) { +<%= $msg %><br/> +% } +</td> </tr> % } </table> |