Lines 157-164
$sth->execute(@query_params);
Link Here
|
157 |
my @reservedata; |
157 |
my @reservedata; |
158 |
while ( my $data = $sth->fetchrow_hashref ) { |
158 |
while ( my $data = $sth->fetchrow_hashref ) { |
159 |
my $thisratio = $data->{reservecount} / $data->{itemcount}; |
159 |
my $thisratio = $data->{reservecount} / $data->{itemcount}; |
160 |
my $ratiocalc = ceil($data->{reservecount}/$ratio - $data->{itemcount}); |
160 |
my $copies_to_buy = ceil($data->{reservecount}/$ratio - $data->{itemcount}); |
161 |
$ratiocalc >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause |
161 |
$thisratio >= $ratio or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause |
162 |
push( |
162 |
push( |
163 |
@reservedata, |
163 |
@reservedata, |
164 |
{ |
164 |
{ |
Lines 182-188
while ( my $data = $sth->fetchrow_hashref ) {
Link Here
|
182 |
itype => [split('\|', $data->{l_itype})], |
182 |
itype => [split('\|', $data->{l_itype})], |
183 |
reservecount => $data->{reservecount}, |
183 |
reservecount => $data->{reservecount}, |
184 |
itemcount => $data->{itemcount}, |
184 |
itemcount => $data->{itemcount}, |
185 |
ratiocalc => sprintf( "%.0d", $ratiocalc ), |
185 |
copies_to_buy => sprintf( "%d", $copies_to_buy ), |
186 |
thisratio => sprintf( "%.2f", $thisratio ), |
186 |
thisratio => sprintf( "%.2f", $thisratio ), |
187 |
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0, |
187 |
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0, |
188 |
listcall => [split('\|', $data->{listcall})] |
188 |
listcall => [split('\|', $data->{listcall})] |