Lines 156-167
sub _get_url {
Link Here
|
156 |
sub _service_throttle { |
156 |
sub _service_throttle { |
157 |
my ($service_type,$daily_limit) = @_; |
157 |
my ($service_type,$daily_limit) = @_; |
158 |
my $dbh = C4::Context->dbh; |
158 |
my $dbh = C4::Context->dbh; |
159 |
my $sth = $dbh->prepare("SELECT service_count FROM services_throttle WHERE service_type=?"); |
159 |
my $sth = $dbh->prepare(q{ SELECT service_count FROM services_throttle WHERE service_type=? }); |
160 |
$sth->execute($service_type); |
160 |
$sth->execute($service_type); |
161 |
my $count = 1; |
161 |
my $count = 0; |
162 |
|
162 |
|
163 |
while (my $counter = $sth->fetchrow_hashref()) { |
163 |
if ($sth->rows == 0) { |
164 |
$count = $counter->{service_count} if $counter->{service_count}; |
164 |
# initialize services throttle |
|
|
165 |
my $sth2 = $dbh->prepare(q{ INSERT INTO services_throttle (service_type, service_count) VALUES (?, ?) }); |
166 |
$sth2->execute($service_type, $count); |
167 |
} else { |
168 |
$count = $sth->fetchrow_array; |
165 |
} |
169 |
} |
166 |
|
170 |
|
167 |
# we're over the limit |
171 |
# we're over the limit |
Lines 169-175
sub _service_throttle {
Link Here
|
169 |
|
173 |
|
170 |
# not over the limit |
174 |
# not over the limit |
171 |
$count++; |
175 |
$count++; |
172 |
$sth = $dbh->do("UPDATE services_throttle SET service_count=$count WHERE service_type='xisbn'"); |
176 |
my $sth3 = $dbh->prepare(q{ UPDATE services_throttle SET service_count=? WHERE service_type=? }); |
|
|
177 |
$sth3->execute($count, $service_type); |
178 |
|
173 |
return undef; |
179 |
return undef; |
174 |
} |
180 |
} |
175 |
|
181 |
|
176 |
- |
|
|