X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_commod;h=34b1347f20f5034315a1821d535cd6de40f8f8e2;hp=a5c8846491dee9006406bc7c7fb3c1e2573b47a6;hb=880b063ca880504e85bbeba2e37fc8faa187947e;hpb=92ddda950c5bbbaf3dfcdc9ca41409ce248f43d5 diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index a5c8846..34b1347 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -49,9 +49,10 @@ my ($commodname,$commodid); my $qa= \%ARGS; %perl> -
+ | 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; +% my $rowix= 0; +% 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 %> |