Permalink
Browse files

Merge pull request #27 from shibayu36/cache-sheets

sheetsをmemoize
  • Loading branch information...
hitode909 committed Sep 16, 2018
2 parents c2512a8 + d7f713d commit 72d16ca244ff716622eb2d48669d2c51724ac88e
Showing with 5 additions and 2 deletions.
  1. +5 −2 webapp/perl/lib/Torb/Web.pm
@@ -235,6 +235,8 @@ sub get_events {
return @events;
}
my $sheets;
sub get_event {
my ($self, $event_id, $login_user_id) = @_;
@@ -249,10 +251,11 @@ sub get_event {
$event->{sheets}->{$rank}->{remains} = 0;
}
my $sheets = $self->dbh->select_all('SELECT * FROM sheets ORDER BY `rank`, num');# TODO: ハードコード
$sheets ||= $self->dbh->select_all('SELECT * FROM sheets ORDER BY `rank`, num');# TODO: ハードコード
my $reservations_by_sheet_ids = { map { ($_->{sheet_id} => $_) } @{$self->dbh->select_all('SELECT * FROM reservations WHERE event_id = ? AND canceled_at IS NULL GROUP BY event_id, sheet_id HAVING reserved_at = MIN(reserved_at)', $event->{id})} };
for my $sheet (@$sheets) {
for my $_sheet (@$sheets) {
my $sheet = { %$_sheet };
$event->{sheets}->{$sheet->{rank}}->{price} ||= $event->{price} + $sheet->{price};
$event->{total} += 1;

0 comments on commit 72d16ca

Please sign in to comment.