Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Commit

Permalink
ticket_id決め打ちでとりあえず
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Nov 3, 2012
1 parent b963a3b commit 81667ca
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/perl/lib/Isucon2.pm
Expand Up @@ -141,15 +141,23 @@ get '/ticket/:ticketid' => [qw(recent_sold)] => sub {
});
};

post '/ticket/update_table_cache' => sub {
post '/ticket/update_table_cache/:process' => sub {
my ($self, $c) = @_;

state $tickets = $self->dbh->select_all(
'SELECT id FROM ticket',
);
state $variations_cache = {};
my $process = $c->args->{process}; # 1 or 2

#state $tickets2process = $self->dbh->select_all(
# 'SELECT id FROM ticket',
#);
state $tickets2process = {
1 => [1,2],
2 => [3,4,5],
};

my $tickets = $tickets2process->{process};

for my $ticket_id (map { $_->{id} } @$tickets) {
state $variations_cache = {};
for my $ticket_id (@$tickets) {
my $variations = $variations_cache->{ $ticket_id } ||= $self->dbh->select_all(
'SELECT id, name FROM variation WHERE ticket_id = ?', $ticket_id,
);
Expand Down

0 comments on commit 81667ca

Please sign in to comment.