summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-03-29 10:53:45 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-03-29 10:53:45 +0200
commitf8aa6ff141ac37aa8655277c102f1b58cfc776ad (patch)
tree4eea821808c3d399cbf54ac6aac321efaa10ef34 /bin
parent001fa0d3bcc098aaca80ba4b1538796ef0d9e308 (diff)
iris-delay-stats: add view containing departures with -all- messages
Diffstat (limited to 'bin')
-rwxr-xr-xbin/iris-delay-stats21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/iris-delay-stats b/bin/iris-delay-stats
index f2cc5ab..12cfb80 100755
--- a/bin/iris-delay-stats
+++ b/bin/iris-delay-stats
@@ -130,6 +130,27 @@ if ( not table_exists('departures') ) {
}
);
}
+if ( not table_exists('departures_with_messages') ) {
+
+ # only for testing, too inefficient for production
+ # (the current schema saves lots of disk space, but not computation time)
+ $dbh->do(
+ qq{
+ create view departures_with_messages as
+ select train_id, station, scheduled_time, delay, is_canceled,
+ destination, train_type, train_no, line_no, platform, }
+ . join( ", ",
+ map { "(msgtable${_}.train_id is not null) as msg${_}" }
+ ( 1 .. 99 ) )
+ . " from departures "
+ . join(
+ " ",
+ map {
+"left outer join msg_$_ as msgtable$_ using (scheduled_time, train_id)"
+ } ( 1 .. 99 )
+ )
+ );
+}
if ( not table_exists('hr_departures') ) {
$dbh->do(
qq{