summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-02-15 00:45:07 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-02-15 00:45:07 +0100
commit54cdcf251e7be0993050b8be10c800fab0c4dc2c (patch)
treee78e033d9b8ce0256f02b0802d697182d9414f46 /bin
parent5999d91d63b3bea58fc740d21a333b201d2fd243 (diff)
code cleanup
Diffstat (limited to 'bin')
-rwxr-xr-xbin/iris-delay-stats41
1 files changed, 18 insertions, 23 deletions
diff --git a/bin/iris-delay-stats b/bin/iris-delay-stats
index 62c612a..1c534e1 100755
--- a/bin/iris-delay-stats
+++ b/bin/iris-delay-stats
@@ -15,7 +15,7 @@ my $dbname = shift or die("Usage: $0 <station> <database>\n");
my $first_run = not -e $dbname;
-my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", q{}, q{});
+my $dbh = DBI->connect( "dbi:SQLite:dbname=$dbname", q{}, q{} );
if ($first_run) {
my $query = qq{
@@ -31,44 +31,39 @@ if ($first_run) {
train_no int not null,
line_no int,
platform char(16),
- } . join(', ', map { "msg_$_ boolean" } (1..99)) . ')';
+ } . join( ', ', map { "msg_$_ boolean" } ( 1 .. 99 ) ) . ')';
$dbh->do($query);
}
my $status = Travel::Status::DE::IRIS->new(
station => $station,
- lookahead => 60);
-
-my @fields = (qw(train_id station raw_id scheduled_time delay
- is_canceled destination train_type train_no line_no platform));
-push(@fields, map { "msg_$_" } (1..99));
-my $fieldlist = join(', ', @fields);
-my $field_placeholders = join(', ', ('?') x @fields);
+ lookahead => 60
+);
+
+my @fields = (
+ qw(train_id station raw_id scheduled_time delay
+ is_canceled destination train_type train_no line_no platform)
+);
+push( @fields, map { "msg_$_" } ( 1 .. 99 ) );
+my $fieldlist = join( ', ', @fields );
+my $field_placeholders = join( ', ', ('?') x @fields );
my $insert_query = qq{
insert or replace into departures ( $fieldlist ) values ( $field_placeholders )
};
my $sth = $dbh->prepare($insert_query);
-for my $r ($status->results) {
+for my $r ( $status->results ) {
my @msgtypes = (0) x 99;
- for my $m ($r->raw_messages) {
+ for my $m ( $r->raw_messages ) {
$msgtypes[ $m->[1] ] = 1;
}
$sth->execute(
- $r->train_id,
- $station,
- $r->raw_id,
- $r->datetime->epoch,
- $r->delay,
- $r->is_cancelled,
- $r->destination,
- $r->type,
- $r->train_no,
- $r->line_no,
- $r->sched_platform,
- @msgtypes
+ $r->train_id, $station, $r->raw_id,
+ $r->datetime->epoch, $r->delay, $r->is_cancelled,
+ $r->destination, $r->type, $r->train_no,
+ $r->line_no, $r->sched_platform, @msgtypes
);
}