Permalink
Browse files

Merge pull request #35 from shibayu36/set-lock

MySQLのロックを使う
  • Loading branch information...
shibayu36 committed Sep 16, 2018
2 parents cf9452b + d327c9a commit 36a9107827b0ed3b745a29fbfcbb8e9053968cc0
Showing with 3 additions and 1 deletion.
  1. +3 −1 webapp/perl/lib/Torb/Web.pm
@@ -555,7 +555,8 @@ get '/admin/api/reports/sales' => [qw/admin_login_required/] => sub {
my @reports;
my $reservations = $self->dbh->select_all('SELECT r.*, s.rank AS sheet_rank, s.num AS sheet_num, s.price AS sheet_price, e.id AS event_id, e.price AS event_price FROM reservations r INNER JOIN sheets s ON s.id = r.sheet_id INNER JOIN events e ON e.id = r.event_id ORDER BY reserved_at ASC FOR UPDATE');
$self->dbh->select_row("SELECT GET_LOCK('reports', 10);");
my $reservations = $self->dbh->select_all('SELECT r.*, s.rank AS sheet_rank, s.num AS sheet_num, s.price AS sheet_price, e.id AS event_id, e.price AS event_price FROM reservations r INNER JOIN sheets s ON s.id = r.sheet_id INNER JOIN events e ON e.id = r.event_id ORDER BY reserved_at ASC');
my @keys = qw/reservation_id event_id rank num price user_id sold_at canceled_at/;
my $body = "\0" x 15000000;
$body = join(',', @keys) . "\n";
@@ -584,6 +585,7 @@ get '/admin/api/reports/sales' => [qw/admin_login_required/] => sub {
# };
# push @reports => $report;
}
$self->dbh->select_row("select RELEASE_LOCK('reports')");
my $res = $c->req->new_response(200, [
'Content-Type' => 'text/csv; charset=UTF-8',

0 comments on commit 36a9107

Please sign in to comment.