X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=0bd36cbffa4db9e958ce30cbc84521a181e70862;hb=5c74b3871323fe2d06d5fcbdcd6c248a88a9ca00;hp=aeee3cee83d0bf8288ee79903ec005e20b36f4fc;hpb=dbd70ca20132a55c55b5d876b59a85d10f9cdd25;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index aeee3ce..0bd36cb 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -52,6 +52,7 @@ my $qa= \%ARGS;
+ | Prices + | Quantity at price + | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Archipelago | Island - | Best stall - | Best price - | Qty at best + | Stall(s) + | Best + | Median + | Best + | +/-10% + | Any |
<% $row->{'archipelago'} %> - | <% $row->{'islandname'} %> - | <% $row->{'stallname'} %> - | <% $row->{'price'} %> - | <% $row->{'qty'} %> +% $islands->execute($commodid); +% my $island; +% my %ts_sortkeys; +% while ($island= $islands->fetchrow_hashref) { +% my $islandid= $island->{'islandid'}; +% $offers->execute($commodid, $islandid); +% my ($offer, $bestprice, $marginal, @beststalls); +% my $tqty= $island->{'tqty'}; +% my $cqty= ''; +% my $bestqty= ''; +% my $approxqty= ''; +% my $median= '-'; +% while ($offer= $offers->fetchrow_hashref) { +% my $price= $offer->{'price'}; +% my $qty= $offer->{'qty'}; +% length $bestqty or $bestprice= $price; +% if ($price == $bestprice) { +% $bestqty += $qty; +% push @beststalls, $offer->{'stallname'}; +% } +% $cqty += $qty; +% if ($cqty*2 >= $tqty && $median eq '-') { +% $median= $price; +% } +% if ($bestprice*9 <= $price*10 and +% $price*10 <= $bestprice*11) { +% $approxqty += $qty; +% } +% } +% my $stallname; +% +% my $rowid= "id_${bs}_$islandid"; +% my $s= [ ]; +% +% $s->[2]= sprintf "%06d", scalar @beststalls; +% if (!@beststalls) { +% $stallname= '-'; +% } elsif (@beststalls==1) { +% $stallname= $beststalls[0]; +% $s->[2] .= " $stallname"; +% } else { +% $stallname= sprintf "%d offers", scalar @beststalls; +% } +% +% $cqty == $tqty or die "$bs $cqty $tqty $commodid $islandid "; + | ||||||
<% $s->[0]= $island->{'archipelago'} |h %> + | <% $s->[1]= $island->{'islandname'} |h %> + | <% $stallname |h %> + | <% $s->[3]= (length $bestqty ? $bestprice : '-') %> + | <% $s->[4]= $median %> + | <% $s->[5]= $bestqty %> + | <% $s->[6]= $approxqty %> + | <% $s->[7]= $cqty %> |