use common action_query instead of checkin_query vs checkout_query
This commit is contained in:
parent
25f75928e7
commit
e24f895303
1 changed files with 8 additions and 26 deletions
34
index.pl
34
index.pl
|
@ -156,7 +156,7 @@ app->attr(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
app->attr(
|
app->attr(
|
||||||
checkin_query => sub {
|
action_query => sub {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
return $self->app->dbh->prepare(
|
return $self->app->dbh->prepare(
|
||||||
|
@ -167,7 +167,7 @@ app->attr(
|
||||||
sched_time, real_time,
|
sched_time, real_time,
|
||||||
route, messages
|
route, messages
|
||||||
) values (
|
) values (
|
||||||
?, $action_type{checkin}, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?, ?, ?,
|
?, ?, ?, ?,
|
||||||
?, ?,
|
?, ?,
|
||||||
?, ?
|
?, ?
|
||||||
|
@ -176,27 +176,6 @@ app->attr(
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
app->attr(
|
|
||||||
checkout_query => sub {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
return $self->app->dbh->prepare(
|
|
||||||
qq{
|
|
||||||
insert into user_actions (
|
|
||||||
user_id, action_id, station_id, action_time,
|
|
||||||
train_type, train_line, train_no, train_id,
|
|
||||||
sched_time, real_time,
|
|
||||||
route, messages
|
|
||||||
) values (
|
|
||||||
?, $action_type{checkout}, ?, ?,
|
|
||||||
?, ?, ?, ?,
|
|
||||||
?, ?,
|
|
||||||
?, ?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
app->attr(
|
app->attr(
|
||||||
dbh => sub {
|
dbh => sub {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
@ -526,8 +505,9 @@ helper 'checkin' => sub {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $success = $self->app->checkin_query->execute(
|
my $success = $self->app->action_query->execute(
|
||||||
$self->current_user->{id},
|
$self->current_user->{id},
|
||||||
|
$action_type{checkin},
|
||||||
$self->get_station_id(
|
$self->get_station_id(
|
||||||
ds100 => $status->{station_ds100},
|
ds100 => $status->{station_ds100},
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
|
@ -600,8 +580,9 @@ helper 'checkout' => sub {
|
||||||
= first { $_->train_id eq $train_id } @{ $status->{results} };
|
= first { $_->train_id eq $train_id } @{ $status->{results} };
|
||||||
if ( not defined $train ) {
|
if ( not defined $train ) {
|
||||||
if ($force) {
|
if ($force) {
|
||||||
my $success = $self->app->checkout_query->execute(
|
my $success = $self->app->action_query->execute(
|
||||||
$self->current_user->{id},
|
$self->current_user->{id},
|
||||||
|
$action_type{checkout},
|
||||||
$self->get_station_id(
|
$self->get_station_id(
|
||||||
ds100 => $status->{station_ds100},
|
ds100 => $status->{station_ds100},
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
|
@ -622,8 +603,9 @@ helper 'checkout' => sub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $success = $self->app->checkout_query->execute(
|
my $success = $self->app->action_query->execute(
|
||||||
$self->current_user->{id},
|
$self->current_user->{id},
|
||||||
|
$action_type{checkout},
|
||||||
$self->get_station_id(
|
$self->get_station_id(
|
||||||
ds100 => $status->{station_ds100},
|
ds100 => $status->{station_ds100},
|
||||||
name => $status->{station_name}
|
name => $status->{station_name}
|
||||||
|
|
Loading…
Reference in a new issue