Allow journey editing, keep track of edited journey attributes
Provides a workaround for #2
This commit is contained in:
parent
3ae6bda093
commit
bba6721754
3 changed files with 37 additions and 10 deletions
|
@ -277,7 +277,7 @@ sub startup {
|
||||||
return $self->app->dbh->prepare(
|
return $self->app->dbh->prepare(
|
||||||
qq{
|
qq{
|
||||||
update user_actions
|
update user_actions
|
||||||
set sched_time = to_timestamp(?), edited = 1
|
set sched_time = to_timestamp(?), edited = edited | 1
|
||||||
where id = ? and action_id = ?
|
where id = ? and action_id = ?
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -291,7 +291,7 @@ sub startup {
|
||||||
return $self->app->dbh->prepare(
|
return $self->app->dbh->prepare(
|
||||||
qq{
|
qq{
|
||||||
update user_actions
|
update user_actions
|
||||||
set real_time = to_timestamp(?), edited = 1
|
set real_time = to_timestamp(?), edited = edited | 2
|
||||||
where id = ? and action_id = ?
|
where id = ? and action_id = ?
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -304,12 +304,12 @@ sub startup {
|
||||||
return $self->app->dbh->prepare(
|
return $self->app->dbh->prepare(
|
||||||
qq{
|
qq{
|
||||||
insert into user_actions (
|
insert into user_actions (
|
||||||
user_id, action_id, station_id, action_time,
|
user_id, action_id, station_id, action_time, edited,
|
||||||
train_type, train_line, train_no, train_id,
|
train_type, train_line, train_no, train_id,
|
||||||
sched_time, real_time,
|
sched_time, real_time,
|
||||||
route, messages
|
route, messages
|
||||||
) values (
|
) values (
|
||||||
?, ?, ?, to_timestamp(?),
|
?, ?, ?, to_timestamp(?), ?
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
to_timestamp(?), to_timestamp(?),
|
to_timestamp(?), to_timestamp(?),
|
||||||
?, ?
|
?, ?
|
||||||
|
@ -665,6 +665,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
),
|
),
|
||||||
DateTime->now( time_zone => 'Europe/Berlin' )->epoch,
|
DateTime->now( time_zone => 'Europe/Berlin' )->epoch,
|
||||||
|
0,
|
||||||
$train->type,
|
$train->type,
|
||||||
$train->line_no,
|
$train->line_no,
|
||||||
$train->train_no,
|
$train->train_no,
|
||||||
|
@ -778,8 +779,8 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
),
|
),
|
||||||
$now->epoch,
|
$now->epoch,
|
||||||
undef, undef, undef, undef, undef,
|
0, undef, undef, undef, undef,
|
||||||
undef, undef, undef
|
undef, undef, undef, undef
|
||||||
);
|
);
|
||||||
if ( defined $success ) {
|
if ( defined $success ) {
|
||||||
$self->invalidate_stats_cache;
|
$self->invalidate_stats_cache;
|
||||||
|
@ -807,6 +808,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
),
|
),
|
||||||
$now->epoch,
|
$now->epoch,
|
||||||
|
0,
|
||||||
$train->type,
|
$train->type,
|
||||||
$train->line_no,
|
$train->line_no,
|
||||||
$train->train_no,
|
$train->train_no,
|
||||||
|
@ -1289,7 +1291,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
? [ split( qr{[|]}, $raw_route ) ]
|
? [ split( qr{[|]}, $raw_route ) ]
|
||||||
: undef,
|
: undef,
|
||||||
completed => 0,
|
completed => 0,
|
||||||
edited => $edited // 0,
|
edited => $edited << 8,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1313,7 +1315,7 @@ qq{select * from pending_mails where email = ? and num_tries > 1;}
|
||||||
$ref->{no} //= $train_no;
|
$ref->{no} //= $train_no;
|
||||||
$ref->{messages} //= [ split( qr{[|]}, $raw_messages ) ];
|
$ref->{messages} //= [ split( qr{[|]}, $raw_messages ) ];
|
||||||
$ref->{route} //= [ split( qr{[|]}, $raw_route ) ];
|
$ref->{route} //= [ split( qr{[|]}, $raw_route ) ];
|
||||||
$ref->{edited} += $edited;
|
$ref->{edited} |= $edited;
|
||||||
|
|
||||||
if ( $opt{verbose} ) {
|
if ( $opt{verbose} ) {
|
||||||
my @parsed_messages;
|
my @parsed_messages;
|
||||||
|
|
|
@ -46,6 +46,7 @@ sub initialize_db {
|
||||||
action_id smallint not null,
|
action_id smallint not null,
|
||||||
station_id int references stations (id),
|
station_id int references stations (id),
|
||||||
action_time timestamptz not null,
|
action_time timestamptz not null,
|
||||||
|
edited not null,
|
||||||
train_type varchar(16),
|
train_type varchar(16),
|
||||||
train_line varchar(16),
|
train_line varchar(16),
|
||||||
train_no varchar(16),
|
train_no varchar(16),
|
||||||
|
@ -66,7 +67,7 @@ sub initialize_db {
|
||||||
token varchar(80) not null,
|
token varchar(80) not null,
|
||||||
primary key (user_id, type)
|
primary key (user_id, type)
|
||||||
);
|
);
|
||||||
insert into schema_version values (0);
|
insert into schema_version values (2);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +93,19 @@ my @migrations = (
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# v1 -> v2
|
||||||
|
sub {
|
||||||
|
my ($dbh) = @_;
|
||||||
|
return $dbh->do(
|
||||||
|
qq{
|
||||||
|
update user_actions set edited = 0;
|
||||||
|
alter table user_actions
|
||||||
|
alter column edited set not null;
|
||||||
|
update schema_version set version = 2;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
<b><%= $journey->{sched_departure}->strftime('%d.%m.%Y') %></b>
|
<b><%= $journey->{sched_departure}->strftime('%d.%m.%Y') %></b>
|
||||||
</p>
|
</p>
|
||||||
% if ($journey->{edited}) {
|
% if ($journey->{edited}) {
|
||||||
<p>Die Ankunfts- und Abfahrtsdaten wurden nachträglich bearbeitet.</p>
|
<p>
|
||||||
|
∗ Daten wurden manuell eingetragen
|
||||||
|
</p>
|
||||||
% }
|
% }
|
||||||
<table class="striped">
|
<table class="striped">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -54,6 +56,9 @@
|
||||||
% else {
|
% else {
|
||||||
%= $journey->{sched_departure}->strftime('%H:%M');
|
%= $journey->{sched_departure}->strftime('%H:%M');
|
||||||
% }
|
% }
|
||||||
|
% if ($journey->{edited} & 0x0003) {
|
||||||
|
∗
|
||||||
|
% }
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -76,6 +81,9 @@
|
||||||
% else {
|
% else {
|
||||||
%= $journey->{sched_arrival}->strftime('%H:%M');
|
%= $journey->{sched_arrival}->strftime('%H:%M');
|
||||||
% }
|
% }
|
||||||
|
% if ($journey->{edited} & 0x0300) {
|
||||||
|
∗
|
||||||
|
% }
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -92,6 +100,9 @@
|
||||||
<td>
|
<td>
|
||||||
∅ <%= sprintf('%.f', $journey->{kmh_route}) %> km/h
|
∅ <%= sprintf('%.f', $journey->{kmh_route}) %> km/h
|
||||||
(<%= sprintf('%.f', $journey->{kmh_beeline}) %> km/h)
|
(<%= sprintf('%.f', $journey->{kmh_beeline}) %> km/h)
|
||||||
|
% if ($journey->{edited} & 0x0303) {
|
||||||
|
∗
|
||||||
|
% }
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue