X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=c9b17ae6700b72a0e5ba135a14d95ff381ae3a98;hp=aeee3cee83d0bf8288ee79903ec005e20b36f4fc;hb=00ba9271fd8409f29fcae6ee2af15824810bc939;hpb=608bc9e07b5c8a961325fd1b8d5b92f65418b949 diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index aeee3ce..c9b17ae 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -52,6 +52,7 @@ my $qa= \%ARGS;
+ | Prices + | Quantities available + | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Archipelago | Island - | Best stall - | Best price - | Qty at best + | Unique best stall + | Best + | Median + | At best + | Within 10% + | Total |
<% $row->{'archipelago'} %> - | <% $row->{'islandname'} %> - | <% $row->{'stallname'} %> - | <% $row->{'price'} %> - | <% $row->{'qty'} %> +% $islands->execute($commodid); +% my $island; +% 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 $nstalls= @beststalls; +% $cqty == $tqty or die "$bs $cqty $tqty $commodid $islandid "; + | ||||||
<% $island->{'archipelago'} |h %> + | <% $island->{'islandname'} |h %> + | <% $nstalls==0 ? '-' : + $nstalls==1 ? $beststalls[0] : "$nstalls offers" |h %> + | <% length $bestqty ? $bestprice : '-' %> + | <% $median %> + | <% $bestqty %> + | <% $approxqty %> + | <% $cqty %> |